A resourceful newsletter featuring the latest and most important news, articles, books and updates in the world of #javascript π Don't miss our Quizzes!
Let's chat: @nairihar
Post #1811
6.59K
CHALLENGE
const factorial = (function () {
const cache = {};
return function inner(n) {
if (n in cache) return cache[n];
return (cache[n] = n <= 1 ? 1 : n * inner(n - 1));
};
})();
console.log(factorial(5));
console.log(factorial(5));
- π€ 8
- π₯ 5
- π 4






