Write a function named withCount
that will be used to extend the Function.prototype
.
This function will return a new function that will have the same signature and functionality as the original function, but it will also keep track of the number of times it was called via a count
property.
Function.prototype.withCount = withCount;
const sum = (a, b) => a + b;
const sumWithCount = sum.withCount();
sumWithCount(1, 2);
sumWithCount(3, 4);
console.log(sumWithCount.count); // 2
sumWithCount(5, 6);
console.log(sumWithCount.count); // 3