Create a function with no parameters that prints how many times it’s been called.
let printCallTimes = 0;
const randomFunc = () => {
printCallTimes++;
console.log(printCallTimes)
return printCallTimes;
}
randomFunc();
randomFunc();
randomFunc();
console.log(`The function has been called ${printCallTimes} times`);
> 1
> 2
> 3
> "The function has been called 3 times"
Top comments (0)