Exerpad
Exercise 9 · Chapter: ObjectsOptional+50 XP

Fix the Loop

This program loops over an object of ages but prints the wrong values. Fix it so it prints each person's actual age!

Expected output:

Alice is 10 years old
Bob is 12 years old
Charlie is 11 years old
Need a hint?
3 available · costs 5 XP each
javascript
let ages = { Alice: 10, Bob: 12, Charlie: 11 };
for (let name of Object.keys(ages)) {
console.log(name, "is", name, "years old");
}
Output
Run your code to see the output here.