+ 5
[SOLVED] Js help
I had this challange and cant figure out how it work var x = 1e-1; var y = -String(-x*10); alert(y); // output 1 What is e, what is -String and how this work?
2 Antworten
+ 2
e means the scientific notation:
1e-1 = 1 * 10^-1 = 0.1
-x * 10 = -0.1 * 10 = -1
Then, it's turned into a string ("-1"), then made negative; which makes it a number again. -(-1) equals 1.
+ 6
Thank you Airree