Write a function named getDoubleN that takes a number n and returns a new function that takes no arguments.
Every time this second function is invoked, it should return the double of the previous invocation. The first invocation should return the double on n.
const doubleN = getDoubleN(100);
console.log(doubleN()); // should print "200"
console.log(doubleN()); // should print "400"
console.log(doubleN()); // should print "800"
const doubleN = getDoubleN(13);
console.log(doubleN()); // should print "26"
console.log(doubleN()); // should print "52"
console.log(doubleN()); // should print "104"
Unlock all functions
The first 10 functions are free. Get lifetime access to all 100 with a one-time payment — no subscription.
Upgrade to Pro