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
List the keys
easy10 minShow the property names joined by commas.
- 2
List the values
easy10 minShow the property values joined by commas.
- 3
Count the properties
easy10 minShow how many properties an object has.
- 4
Total the values
easy10 minAdd up every value in a scores object.
- 5
Loop over entries
medium10 minBuild a string of each key and value, separated by spaces.
Find the bug(5)
- 1
Fix length used on an object
easy8 minObjects have no length property.
- 2
Fix keys used instead of values
easy8 minThe names are being totalled, not the numbers.
- 3
Fix the method called on the object
easy8 minThese are functions on Object, not methods of your object.
- 4
Fix entries not unpacked
easy8 minEach entry is a pair, so it needs destructuring.
- 5
Fix values used instead of keys
easy8 minThe 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