Skip to main content

JavaScript Object keys and values — exercises and bug fixes

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

    List the keys

    easy10 min

    Show the property names joined by commas.

  2. 2

    List the values

    easy10 min

    Show the property values joined by commas.

  3. 3

    Count the properties

    easy10 min

    Show how many properties an object has.

  4. 4

    Total the values

    easy10 min

    Add up every value in a scores object.

  5. 5

    Loop over entries

    medium10 min

    Build a string of each key and value, separated by spaces.

Find the bug(5)

  1. 1

    Fix length used on an object

    easy8 min

    Objects have no length property.

  2. 2

    Fix keys used instead of values

    easy8 min

    The names are being totalled, not the numbers.

  3. 3

    Fix the method called on the object

    easy8 min

    These are functions on Object, not methods of your object.

  4. 4

    Fix entries not unpacked

    easy8 min

    Each entry is a pair, so it needs destructuring.

  5. 5

    Fix values used instead of keys

    easy8 min

    The property names are wanted, not the numbers.

Ready to write the code?

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

Open the workspace