148k views
5 votes
Open the list10-2.js file and directly below the code populating the links array, declare the htmlCode variable. Store within the variable the following text:

Movie Description Score




Open the list10-2.js file and directly below your previous code create a for loop with a counter variable i that goes from 0 to 9. Each time through the for loop add the following text to the htmlCode variable:


titles_i
summaries_i
ratings_i


where i is the value of the counter variable, and links_i, titles_i, summaries_i, and ratings_i are the values from the links, titles, summaries, and ratings array with index number i.

After the for loop add the following text to the htmlCode variable:



Store the value of the htmlCode variable in the inner HTML of the element with the ID list.

1 Answer

3 votes

Answer:

I cannot actually open or edit files directly. However, I can provide you with the code you need to add in your list10-2.js file. Please add the following code snippet to your file:

// Assuming your links, titles, summaries, and ratings arrays have already been populated

// Declare the htmlCode variable and add the initial text

let htmlCode = `

Movie | Description | Score

------|-------------|------`;

// Create a for loop with a counter variable i that goes from 0 to 9

for (let i = 0; i < 10; i++) {

// Add the text to the htmlCode variable with the respective values from the arrays

htmlCode += `

${titles[i]} | ${summaries[i]} | ${ratings[i]}`;

}

// Add the closing text to the htmlCode variable

htmlCode += `

`;

// Store the value of the htmlCode variable in the inner HTML of the element with the ID list

document.getElementById("list").innerHTML = htmlCode;

Make sure to include this code in your list10-2.js file, and it should work as expected.

User Raphael Castro
by
7.9k points