function memo(func, resolver) {
// your code here
let lookup = new Map()
let result = 0;
return function (...args) {
const key = resolver ? resolver(...args) : args.join('_')
if(!lookup.has(key)){
lookup.set(key, func(...args))
}
console.log(lookup)
return lookup.get(key)
}
}
const func = (arg1, arg2) => {
return arg1 + arg2
}
const memoed = memo(func)
memoed(1, 2)
memoed(1, 2)
memoed(1, 3)