JavaScript Challenge: Day 9
Diffstat:
2 files changed, 18 insertions(+), 1 deletions(-)
@@ -0,0 +1,16 @@
/**
* @param {Function} fn
*/
function memoize(fn) {
const cache = {};
return function(...args) {
const key = JSON.stringify(args);
if (key in cache) {
return cache[key];
}
const functionOutput = fn(...args);
cache[key] = functionOutput;
return functionOutput;
}
}
@@ -545,4 +545,5 @@
for solving problems.
| 2635 | Easy | [Apply Transform Over Each Element in Array](Problems/2635.js) |
| 2665 | Easy | [Counter II](Problems/2665.js) |
| 2666 | Easy | [Allow One Function Call](Problems/2666.js) |
| 2667 | Easy | [Create Hello World Function](Problems/2667.js) |
| 2667 | Easy | [Create Hello World Function](Problems/2667.js) |
| 2623 | Medium | [Memoize](Problems/2623.js) |