Guess the JavaScript Output: Level impossible!
Sadeedpv🥇

Sadeedpv🥇 @sadeedpv

About: Human being

Location:
Kerala, India
Joined:
Feb 19, 2022

Guess the JavaScript Output: Level impossible!

Publish Date: Sep 24 '23
14 13

This post is part of a series called Guess the JavaScript Output
If you like to read Part 1 of the series, see here

So, without any ado, let's get to it:

Today's question(Super tricky):

What does console.log((! + [] + [] + ![]).length) output in JavaScript?

Big Mike solved this in 2 minutes. Can you beat big Mike on this one? Even ChatGPT got this one wrong!!

And Yes, JavaScript is officially crazy!

Comments 13 total

  • Jon Randy 🎖️
    Jon Randy 🎖️Sep 24, 2023

    9. Took about a minute

    • Sadeedpv🥇
      Sadeedpv🥇Sep 24, 2023

      You are a senior dev for a reason 😄

    • Sadeedpv🥇
      Sadeedpv🥇Sep 24, 2023

      Hey Jon, I have been following you on this platform for some time now and I know you've been coding for years. I've reached a stage in my career where I could use some advice. Is there anyway we could get in touch? (I know this is completely unrelated, but I would really appreciate a response here)

      • Jon Randy 🎖️
        Jon Randy 🎖️Sep 25, 2023

        My Twitter is on my profile - you could send a DM there

        • Sadeedpv🥇
          Sadeedpv🥇Sep 26, 2023

          I tried, but only verified users can send messages

          • Jon Randy 🎖️
            Jon Randy 🎖️Sep 26, 2023

            Ah ok. My GMail address shouldn't be too hard to work out

            • Sadeedpv🥇
              Sadeedpv🥇Sep 26, 2023

              Feel free to share it if you're comfortable

  • Vladas Saulis
    Vladas SaulisSep 24, 2023

    Three "NaN"s. Length = 9.

    • Sadeedpv🥇
      Sadeedpv🥇Sep 24, 2023

      You guessed the output, but the reasoning is wrong.
      So, let me explain:
      First ! + [] negates to true (+[] will result in 0),
      Then we got "![]" ([] ==> true but ![] == false)
      so "truefalse".length will give us 9

  • Peter Vivo
    Peter VivoSep 24, 2023

    try this: codewars.com/kata/59a421985eb5d4bb...

    You need to write a function f that returns the string Hello, world!.

    Requirement: Every line must have at most 1 character, and total number of lines must be less than 145.

    Hint: It's possible to complete this in less than 99 (tsukumo) lines.

    • Sadeedpv🥇
      Sadeedpv🥇Sep 24, 2023

      Wait! is this even possible in JavaScript? 🤔

      • Peter Vivo
        Peter VivoSep 24, 2023

        yes it is possible, I am solved, but few others too.

  • Mark M. Florida
    Mark M. FloridaSep 29, 2023

    I don't know because I'm not a computer!

Add comment