0
Unexpected Answer ...why the result is this ( see description) and how ?
JavaScript Challenge What is the output of this code? var X = 10; var x = 7; var x = 5; var z = (x* x) - (x); X document.write(X - x); document.write(z); Result/ans: 342
2 Antworten
+ 1
Hello there!
The result of this will be 520 for the following reasons:
- 'document.write(X-x)' will result 5, because the value of 'X' == 10, and 'x' == 5.
== 10 - 5 = 5
- 'document.write(z)' will print 20, because z == (x*x) - x.
This will result 5*5 - 5 (==20).
At the end the Javascript will print these 2 variables, 5 & 20, in the document.
You didn't separate these 2 outputs with space, so it will be 520.
ℹ️ Some tips:
- avoid declaring some name of variables one time in UPPER- and one time downcase.
- the 'X' after ... - (x); X is useless, try to recheck perhaps if it's a type error. :)
https://code.sololearn.com/WAeEKLtbrTT1/?ref=app
0
Thanks friend ,
I understood ....But this code is the question in sololearn 's challenge and the ans 342 is given by the program of sololearn .........