...

/

Exercise on the for-of loop

Exercise on the for-of loop

We will use the for-of loop to search through data and obtain our desired values.

We'll cover the following...

Exercise 1:

Open the developer tools on any website. Locate the first character of all headings, and log the concatenation of the first characters.

let text = '';
let nodes = // Write code here
for ( let node of nodes ) {
// Write code here
};
console.log( text );

Explanation:

The data from the headings can be obtained in several ways. The solution uses

document.querySelectorAll('h1', 'h2', 'h3', 'h4', 'h5', 'h6')

This query returns those 6 headings in ...