r/learnjavascript • • Oct 11 '20

Wired way to learn javascript :D

Post image
466 Upvotes

30 comments sorted by

View all comments

Show parent comments

48

u/annathergirl Oct 11 '20

But why two a's after it? I'm not too savvy with JS but according to my bad logic there's one a too much.

34

u/draq100 Oct 11 '20

('b'+'a'+ +'anything'+'a').toLowerCase() works too

part +'anything' is equivalent of Number('anything') and returns NaN

+ '' gives 0 as it's Number('')

21

u/annathergirl Oct 11 '20

That makes sense. But why does it log "banana" and not "bananaa" in the screenshot?

12

u/frenchy641 Oct 12 '20

What is 'Ba'++ = to?

so 'B'+'a'+'NaN'+'a'

baNANa