+ 2

Could you explain the result of this expression in JS?

Please explain the result of the following expression: 'b' + 'a' + + 'a' + 'a' Result: 'baNaNa'

11th Sep 2017, 6:41 AM
Alexander Kurnaev
Alexander Kurnaev - avatar
2 ответов
+ 6
😂 'b' + 'a' == ba ++ 'a' == NaN + 'a' == a => baNaNa 😂 //should be like this var a,b,c; a = "b"+"a"; b = +"a"; c="a" document.write(a+b+c)
11th Sep 2017, 6:48 AM
Nomeh Uchenna Gabriel
Nomeh Uchenna Gabriel - avatar
+ 1
the first b and a are strings so they concatenate to 'ba'. you have an empty space + a which gives NaN + your a string at the end.
11th Sep 2017, 8:48 AM
Ashinze Ekene
Ashinze Ekene - avatar