Skip to main content

JavaScript == vs === — exercises and bug fixes

5 hands-on exercises and 5 find-the-bug challenges for the JavaScript == vs === lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.

Exercises(5)

  1. 1

    Compare loosely

    easy10 min

    Report whether a string and a number are loosely equal.

  2. 2

    Compare strictly

    easy10 min

    Report whether they are strictly equal.

  3. 3

    Check for null or undefined

    easy10 min

    Use one check that catches both.

  4. 4

    Compare two objects

    easy10 min

    Report whether two identical-looking objects are equal.

  5. 5

    Convert then compare

    medium10 min

    Convert the text before comparing it strictly.

Find the bug(5)

  1. 1

    Fix the loose comparison

    easy8 min

    A string and a number should not be treated as equal.

  2. 2

    Fix the object compared by contents

    easy8 min

    Two objects are equal only if they are the same object.

  3. 3

    Fix the strict null check

    easy8 min

    Strict equality misses undefined when checking for null.

  4. 4

    Fix the loose comparison against text

    easy8 min

    The number should not be treated as equal to the string.

  5. 5

    Fix the empty string compared to zero

    easy8 min

    Loose equality says they are equal, which is not wanted.

Ready to write the code?

The editor, the automatic checks and the worked solutions open up with an account.

Open the workspace