codetogo.io
codetogo.io copied to clipboard
Use Case Suggestion: On topic "How to increment a variable in JavaScript"
The answer is not correct and not complete. (from : https://codetogo.io/how-to-increment-a-variable-in-javascript/
The original answer is (postfix):
input :
let counter = 0; counter++;
output :
1
<-- Not correct
// Should return 0
To add to the answer :
Increment/decrement using (prefix) :
input:
let counter = 0;
++counter;
output :
1
See doc : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Increment