Skip to main content

JavaScript Objects — exercises and bug fixes

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

    Create an object

    easy10 min

    Create a person object with a name and show the name.

  2. 2

    Read with brackets

    easy10 min

    Read a property using a key held in a variable.

  3. 3

    Add a property

    easy10 min

    Add a year to a car object and show the brand and year together.

  4. 4

    Check a missing property

    easy10 min

    Show the type of a property that was never set.

  5. 5

    Delete a property

    medium10 min

    Delete one property and show how many are left.

Find the bug(5)

  1. 1

    Fix the dot used with a variable key

    easy8 min

    A dot looks for a property literally named key.

  2. 2

    Fix the array brackets

    easy8 min

    Square brackets make an array, so the named properties are lost.

  3. 3

    Fix the equals sign in the literal

    easy8 min

    Object properties use a colon, not an equals sign.

  4. 4

    Fix the misspelled property

    easy8 min

    The name is read with a typo, so nothing is found.

  5. 5

    Fix the property never removed

    easy8 min

    Setting a property to undefined leaves it in place.

Ready to write the code?

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

Open the workspace