Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Challenge: Iteration with for...of | Mastering Arrays
course content

Course Content

JavaScript Data Structures

Challenge: Iteration with for...ofChallenge: Iteration with for...of

Task

You are given an array of objects. Each object represents a friend's information. The task is to create a for...of loop to iterate through the array and add one more property to each object that should be: online: false.

  1. Use a for...of loop to iterate through the friends array.
  2. Inside the for...of loop, use the dot notation to add the property.

Expected Output:

  1. To create a for...of loop, use the following syntax: for (const element of array) { ... }.
  2. Use the dot notation (.) to add a property (online) and assign it the value false.

Everything was clear?

Section 4. Chapter 8
course content

Course Content

JavaScript Data Structures

Challenge: Iteration with for...ofChallenge: Iteration with for...of

Task

You are given an array of objects. Each object represents a friend's information. The task is to create a for...of loop to iterate through the array and add one more property to each object that should be: online: false.

  1. Use a for...of loop to iterate through the friends array.
  2. Inside the for...of loop, use the dot notation to add the property.

Expected Output:

  1. To create a for...of loop, use the following syntax: for (const element of array) { ... }.
  2. Use the dot notation (.) to add a property (online) and assign it the value false.

Everything was clear?

Section 4. Chapter 8
some-alt