This section is included to assist the students to perform the activities in the book. It includes detailed steps that are to be performed by the students to achieve the objectives of the activities.

Chapter 1: JavaScript, HTML, and the DOM

Activity 1: Extracting Data from a Page


  1. Initialize a variable to store the entire content of the CSV:

    var csv = 'name,price,unit\n';

  2. Query the DOM to find all the elements that represent each product. Notice how we wrap the HTMLCollection instance returned in Array.from so that we can handle it like a normal array:

    var elements = Array.from(document.getElementsByClassName('item'));

  3. Iterate over each element found:

    elements.forEach((el) => {});

  4. Inside the closure, using the ...

Get Professional JavaScript now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.