codetogo.io icon indicating copy to clipboard operation
codetogo.io copied to clipboard

Use Case Suggestion: On topic "How to increment a variable in JavaScript"

Open loddaa opened this issue 1 year ago • 0 comments

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

loddaa avatar Mar 28 '23 12:03 loddaa