+ 11

How the answer will come 8?

I am not getting,how to solve this? var a=1,x; x=++a + ++a; x +=a; alert(x); Plz explain

20th Sep 2020, 11:40 AM
‎Ashwin Maurya
‎Ashwin Maurya - avatar
2 Respostas
+ 11
first time, line 1 ,a=1 line 2 ,x=++a+ ++a (here first time a=2 and second time a=3 ) so x=2+3 =5 line 3 x+=a (a=3 now and x=5 before .So in this line x=5+3 =8 so the value of x is 8
20th Sep 2020, 11:45 AM
The future is now thanks to science
The future is now thanks to science - avatar
+ 4
Alphin K Sajan This question is from challenges ,so i dont think it should be worng🤔
20th Sep 2020, 11:49 AM
‎Ashwin Maurya
‎Ashwin Maurya - avatar