This function is supposed to output 0 if value passed in is larger than 100 and return (value+1) if the value passed in is lesser than 100.
const counterFunc = (counter) => (counter>100 ? counter = 0: counter+1 );
console.log(counterFunc(55)); //output 56, which is what I want
but when I replace counter+1 with counter++ is returns 55 instead
const counterFunc = (counter) => (counter>100 ? counter = 0: counter++ );
console.log(counterFunc(55)); //outputs 55
I used counter++ initially but when I noticed that I'm not getting the expected result i switched to counter + 1. for some magical (or extremely technical reason) the latter works but the former does not. I would like to know why counter++ doesn't work in this scenario.