As an illustration, consider a scenario where you are invoking a function with two parameters. The first parameter represents the initial value while the second parameter is the maximum value. Every time you invoke this function, it will increment from the initial value to the maximum value at an interval of one second.
let count;
function Increment(number, maxNumber) {
setInterval(() => {
if (number == maxNumber) {
return false;
} else {
count = number++;
return count;
}
}
, 100)
}
console.log(Increment(10, 40));