0

Why given bellow code give the answer 60 ?

var x=10; x*=2; while(x<30){ x+=5; x=y; } alert(y+x);

31st Jul 2020, 5:43 PM
ILLUMINATIE
ILLUMINATIE - avatar
5 Réponses
+ 6
x*=2; #x=20 while(x<30){ x+=5; x=y; } After first itteration: x = y = 25 After second: x=y=30 alert(y+x); #30+30=60
31st Jul 2020, 5:51 PM
Julia Shabanova
Julia Shabanova - avatar
+ 1
In the while you mentioned x = y, so y and x are the same value in the end of the while cycle. Y automatically becomes 30. Every time in this cycle y becomes similar to x
31st Jul 2020, 5:51 PM
Иванов Григорий
Иванов Григорий - avatar
0
What is y in this code? What is it's initial value?
31st Jul 2020, 7:46 PM
benjamin
- 2
10-20-30-0
31st Jul 2020, 5:48 PM
Thijmen Fickweiler
- 2
i dont no🤷‍♂️
31st Jul 2020, 5:48 PM
Thijmen Fickweiler