Bummer! This is just a preview. You need to be signed in with an account to view the entire instruction.

Well done!

You have completed (UPI) Chapter 11: Managing Errors, Debugging, and Handling Events in JavaScript!

Instruction

Iterating over Object properties

In JavaScript, Objects are not iterable unless they implement the iterable protocol. Therefore, you cannot use for...of to iterate over the properties of an object.

const obj = { France: "Paris", England: "London" };
for (const p of obj) {
 // …
} // TypeError: obj is not iterable

Instead, you have to use Object.keys or Object.entries to iterate over the properties or entries...