Category Archives: riddles

JavaScript code riddle

What do you think of this post?
  • Awesome (100.0%)
  • Interesting (0.0%)
  • Useful (0.0%)
  • Boring (0.0%)
  • Sucks (0.0%)

Today I was talking to a friend about some codding “riddles” and I remembered a riddle in C code that I saw long time ago.

The riddle is like this: having the following JS code

var c;

// YOU CAN NOT CHANGE THE FOLLOWING CODE
if (c===c) {
    alert ("YOU LOSE!");
}
else {
    alert ("YOU WIN!");
}

By changing only the c value you have to make the code display the “YOU WIN!” message.

Leave you answer in the comments… :)

What do you think of this post?
  • Awesome (100.0%)
  • Interesting (0.0%)
  • Useful (0.0%)
  • Boring (0.0%)
  • Sucks (0.0%)