const memoize = fn => (...args) => { fn.cache = fn.cache || {} return fn.cache[args] ? fn.cache[args] : (fn.cache[args] = fn.apply(this,args)) } const memoizedFunction = memoize(funtionToMemoize) memoizedFunction(args)