export const memoizedAdd = () => {
const cache = new Map();
return (...args) => {
const key = args.join();
const cached = cache.get(key);
if (cached) {
console.log(`Returning cached value for ${key}`);
return cached;
} else {
const result = args.reduce((total, val) => total + val);
return cache.set(key, result) && result;
}
}
}