Function Cache
Создайте функцию, которая будет кешировать свой результат, в зависимости от входящих аргументов и будет выполнять сложные вычисления только тогда, когда у неё нет закешированного значения.
Примеры:
var complexFunction = function(arg1, arg2) { /* complex calculation in here */ };
var cachedFunction = cache(complexFunction);
cachedFunction('foo', 'bar');
// complex function should be executed
cachedFunction('foo', 'bar');
// complex function should not be invoked again, instead the cached result should be returned
cachedFunction('foo', 'baz');
// should be executed, because the method wasn't invoked before with these arguments
👉 @seniorFront