Having trouble with incrementing and decrementing a number using a timer in my code. It seems to not be working properly...
let num = 0,
maxNum = 5,
timerFunc = function() {
if (num < maxNum) {
num++;
console.log(num); //working fine
}
if (num == maxNum) {
num--;
console.log(num); //not functioning as expected
}
setTimeout(timerFunc, 60);
};
timerFunc();