Home > shorts > JavaScript quiz time

JavaScript quiz time


What is the output of the console?!

console.log(
  ('b' + 'a' + + 'a' + 'a').toLowerCase()
)

The answer is 'banana' aka 🍌

  1. " + 'a' " will give NaN
  2. You can imagen it as ('b' + 'a' + NaN + 'a') -> ('baNaNa')
  3. And all gets converted to lower case (NaN -> nan)
© 2021, Andrew Losseff