+ 3

Could someone explain me how this code works line to line? Thanks.

var X=10; var x=7; var c=5; var z=(x*x)-(x); document.write(X-x); document.write(z);

3rd May 2018, 1:14 PM
Rastislav Romanec
Rastislav Romanec - avatar
2 Answers
+ 9
z= 7*7-7 = 42 X-x= 10-7 =3
3rd May 2018, 1:24 PM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
+ 6
X is set to 10 x is set to 7 c is set to 5. // unused var z is set to x*x-x ==> 7*7-7 ==> 42 prints X-x ==> 10-7 ==> 3 prints z ==> 42
3rd May 2018, 1:32 PM
Samuel Vincent
Samuel Vincent - avatar