Javascript Puzzlers

Here are a few javascript puzzlers. If you want to try them yourself, all of the statements below evaluate to true and you have to work out what values could make that happen…

Starting simply, name a value that is not === to itself:

    a !== a

And its dual – name two values that are different but do === each other. The second part of this puzzle is to provide a statement that can distinguish b and c. (clue – don’t look unless you’re stuck)

    b === c

What’s a value that seems to be the same as its complement (there are quite a few possibilities):

    !d == d

How about something that seems to give 42 more than you might expect (Can you find a second way of doing the same thing)?

    (e + 4 === 42) && ("4" + e.toString() === "42")

How did you do?

5 thoughts on “Javascript Puzzlers

  1. 1) a = NaN
    2) a = 0, b = -0 ( 1/a = Infinity, 1/b = -Infinity) => Infinity !== -Infinity && 0 === -0
    3) a = “0”

    4) En cours :D

Leave a Reply to kybernetikos Cancel reply

Your email address will not be published. Required fields are marked *