To label every setlist item, compare a loop that acts on each item with a method that builds a new array. Run both checkpoints in the Console.
Iteration methods let you work with every item in an array. This lesson pairs forEach() and map() so learners can compare a side-effect loop with a transformation method.
const books = ["Dune", "Kindred", "Beloved"];
const labels = books.map((book) => `Read: ${book}`);
console.log(labels);
map() to create doubledNumbers, producing Number: 1, Number: 2, Number: 3 | [2,4,6] in the supplied probe.Use forEach() to push formatted labels into an existing array.
Use map() to create a new doubled array in one expression.