0
1. How is var a = 9? in this Javascript Challenge.I thought the increement is to happen after the substraction.
Fill in the blank to output 3. var a = ; var b = 5; b++; alert(a - b) 2. What number will output 3, if b++ is substituted with ++b.
3 ответов
+ 5
The 3rd statement, b++, is a standalone statement which increase b by 1.
Even if it is written in ++b, it does the same thing because it is a complete statement.
Therefore, before alert b is equal to 6, and 9 minus 6 equals to 3.
I put them into this code so you can see the action.
https://sololearn.com/compiler-playground/WFMJicdwt5H7/?ref=app
+ 4
Dr Melchisedec Bankole ,
For the increment to happen after the subtraction, you'd have to write it like this.
alert(a - b++)
+ 3
Code executes step by step so not possible of increment after substraction.