0
var n = 5 ; alert(n-=2) = 3 or alert(n-2)= 3 . When would anyone use ( -=2 ) when ( n-2 ) is straight forward ? 🤔🤔🤔🤔
2 odpowiedzi
+ 3
when you use a-=2
the value of a decreases 2.
when you use a-2
the value of a doesn't decrease.
So the value of a still remains the same.
Here is an example:
https://code.sololearn.com/Wa23A179a20A
+ 2
if you want to assign the result of calculation to variable n use n -= 2