Skip to main content

JavaScript Keywords — exercises and bug fixes

5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Keywords 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

    Use the const keyword

    easy10 min

    Declare a constant and display it.

  2. 2

    Use the typeof keyword

    easy10 min

    Report the type of true.

  3. 3

    Use the return keyword

    easy10 min

    Return a value from a function and show it.

  4. 4

    Use the new keyword

    easy10 min

    Create a Date and confirm it worked.

  5. 5

    Use the this keyword

    medium10 min

    Read a property through this inside a method.

Find the bug(5)

  1. 1

    Fix the reserved word used as a name

    easy8 min

    class is a reserved keyword and cannot be a variable name.

  2. 2

    Fix the missing return

    easy8 min

    The function computes a value but never returns it.

  3. 3

    Fix the missing new keyword

    easy8 min

    Date without new returns a string, not a Date object.

  4. 4

    Fix the wrong typeof target

    easy8 min

    This reports the type of a string, not a boolean.

  5. 5

    Fix this inside an arrow function

    easy8 min

    An arrow method has no own this, so the lookup fails.

Ready to write the code?

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

Open the workspace