function compareArrays(arr1, arr2){
console.log(arr1.length == arr2.length && arr1.every((v,i)=>v === arr2[i]));
return arr1.length == arr2.length && arr1.every((v,i)=>v === arr2[i]);
}
function memorize(fn){
const memory = [
{
args: [3, 4],
result: 7
},
{
args: [1, 3],
result: 4
}
];
return (...args) =>{
memory.find(item =>{
if(compareArrays(item.args, [...args]) === true){
console.log(fn(...args));//7
return fn(...args);
}
})
}
}
const resultFunction = memorize((a,b) => a + b);
console.log(resultFunction(3, 4));//undefined