DEV Community

Discussion on: Guess the output of this JS code

Collapse
lukeshiru profile image
LUKESHIRU

The output of this code is me telling you to fix that code 🤣 ... jokes aside, if you see a pice of code like this, your first question should be:

What were you trying to do?

I'm sure that if you see this in "production", there was a typo somewhere, because the actual behavior (looping down from 10 to 6), can be achieved with a much clearer code, so is surely a mistake if you see something like that.

Cheers!

Collapse
0shuvo0 profile image
Shuvo Author

Yes, It was just a trick question for newbies

Collapse
lukeshiru profile image
LUKESHIRU

I know, and my comment is explaining "newbies" that you don't always have to resolve the problem in interviews. Sometimes the best answer is: "I don't understand your code/intention", instead of banging your head against the keyboard.