result of console.log
kaitlynnT (1)

This is my code(JS) as below

let x = 3
console.log(x++)

It showed 3 instead of 4.

please help to answer it.
Thanks

You are viewing a single comment. View All
a5rocks (774)

x++ returns the previous x, ++x returns the new x.

Both increment so this would work:

let x = 3;
x++; // or ++x;
console.log(x);
kaitlynnT (1)

@a5rocks thanks for your help!