D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
kyleshevlin
Full window
Github gist
JS Bin // source http://jsbin.com/kawomaxiga
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>JS Bin</title> </head> <body> <script id="jsbin-javascript"> "use strict"; function memoizedFibSum(num) { if (!this.cache) { this.cache = {}; } console.log(this.cache); if (this.cache[num]) { return this.cache[num]; } if (num <= 1) { this.cache[num] = num; return num; } else { var sum = memoizedFibSum(num - 1) + memoizedFibSum(num - 2); this.cache[num] = sum; return sum; } } console.log(memoizedFibSum(0)); console.log(memoizedFibSum(1)); console.log(memoizedFibSum(3)); console.log(memoizedFibSum(10)); </script> <script id="jsbin-source-javascript" type="text/javascript">function memoizedFibSum (num) { if (!this.cache) { this.cache = {} } console.log(this.cache) if (this.cache[num]) { return this.cache[num] } if (num <= 1) { this.cache[num] = num return num } else { const sum = memoizedFibSum(num - 1) + memoizedFibSum(num - 2) this.cache[num] = sum return sum } } console.log(memoizedFibSum(0)) console.log(memoizedFibSum(1)) console.log(memoizedFibSum(3)) console.log(memoizedFibSum(10)) </script></body> </html>