+ 2

Whats: var a = "b" - 8 ?

Asciicode?

20th May 2019, 11:38 PM
Konstx7 LP
Konstx7 LP - avatar
4 Respostas
+ 3
In your second example you get 1052. "10" + 5 --> add 5 to the String //105 3 - "1" --> //do the math //3 - 1 = 2 a + b --> a connected string //"105" + 2 = "1052"
21st May 2019, 12:47 AM
Denise Roßberg
Denise Roßberg - avatar
+ 2
Output: NaN You need charCodeAt() to get the ascii value. var a = "b"; document.write(a.charCodeAt(a)); //98 //calc with ascii value var a = "b"; var b = a.charCodeAt(a) - 8; document.write(b); //90
21st May 2019, 12:16 AM
Denise Roßberg
Denise Roßberg - avatar
+ 2
thanks. but i dont understand why there are so many challenges with multiplacation of those code examples. For example: var a = "10" + 5; var b = 3 - "1"; alert (a + b); i mean yes, i know that the plus stands for string addition, but the answer of this code example (in this kind in a challenge) was only one number. I am confused. Shitty Javascript or quiz maker...
21st May 2019, 12:23 AM
Konstx7 LP
Konstx7 LP - avatar
+ 2
okay thats interesting so if b would be 3 - "32" // = 29? that makes no sense for me or is it because of the minus?
21st May 2019, 12:50 AM
Konstx7 LP
Konstx7 LP - avatar