[SOLVED] Js help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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?

18th Jul 2019, 7:01 AM
PanicS
PanicS - avatar
2 Answers
+ 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.
18th Jul 2019, 7:38 AM
Airree
Airree - avatar
+ 6
Thank you Airree
18th Jul 2019, 7:41 AM
PanicS
PanicS - avatar