5 hands-on exercises and 5 find-the-bug challenges for the JavaScript for in Loop lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Join the property names of the object with a dash.
Count how many properties the object has.
Add every value in the object together and show the total.
Find which subject scored 25 and show its name.
Build a string of every property as name=value, separated by commas.
The loop variable holds the property name, not the value.
Adding the property name instead of the value gives the wrong total.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspacescores.key looks for a property actually named "key".
This counts the characters of each name instead of the properties.
Without break the loop keeps going and reports the last match.