Tobias is a selftaught web developer who loves reading, coding and cooking. On sunny days, he can be found hiking through the Teutoburg Forest, on rainy days he preferes a good fiction novel
When your run 'a' + + 'a' you're doing 'a' + +'a'. JavaScript tries to cast +'a' to a number which is cleary impossible; so it returns NaN (Not a Number) and then it concatenates the NaN to other chars, creating the baNaNa string. The magic happens with the toLowerCase() method :)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Came for the meme, stayed for the code.
Stuff like this is the reason why I love javascript.
Had my first wtf moment when trying:
('b' + 'a' + + 'a' + 'a').toLowerCase()
Can you explain it?
When your run
'a' + + 'a'
you're doing'a' + +'a'
. JavaScript tries to cast+'a'
to a number which is cleary impossible; so it returns NaN (Not a Number) and then it concatenates the NaN to other chars, creating the baNaNa string. The magic happens with the toLowerCase() method :)