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
Create an object
easy10 minCreate a person object with a name and show the name.
- 2
Read with brackets
easy10 minRead a property using a key held in a variable.
- 3
Add a property
easy10 minAdd a year to a car object and show the brand and year together.
- 4
Check a missing property
easy10 minShow the type of a property that was never set.
- 5
Delete a property
medium10 minDelete one property and show how many are left.
Find the bug(5)
- 1
Fix the dot used with a variable key
easy8 minA dot looks for a property literally named key.
- 2
Fix the array brackets
easy8 minSquare brackets make an array, so the named properties are lost.
- 3
Fix the equals sign in the literal
easy8 minObject properties use a colon, not an equals sign.
- 4
Fix the misspelled property
easy8 minThe name is read with a typo, so nothing is found.
- 5
Fix the property never removed
easy8 minSetting 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