120k views
1 vote
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:

Image 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:

Image 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:

The other image

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

Open the list10-2.js file and directly below the code populating the links array, declare-example-1
Open the list10-2.js file and directly below the code populating the links array, declare-example-1
Open the list10-2.js file and directly below the code populating the links array, declare-example-2
Open the list10-2.js file and directly below the code populating the links array, declare-example-3

1 Answer

6 votes

Answer:

// Populating links array

var links = ["link0", "link1", "link2", "link3", "link4", "link5", "link6", "link7", "link8", "link9"];

// Populating titles array

var titles = ["Title 1", "Title 2", "Title 3", "Title 4", "Title 5", "Title 6", "Title 7", "Title 8", "Title 9", "Title 10"];

// Populating summaries array

var summaries = ["Summary 1", "Summary 2", "Summary 3", "Summary 4", "Summary 5", "Summary 6", "Summary 7", "Summary 8", "Summary 9", "Summary 10"];

// Populating ratings array

var ratings = ["Rating 1", "Rating 2", "Rating 3", "Rating 4", "Rating 5", "Rating 6", "Rating 7", "Rating 8", "Rating 9", "Rating 10"];

// Initializing htmlCode variable

var htmlCode = "Image Movie Description Score";

// Adding data to htmlCode variable

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

htmlCode += "<br>Image " + titles[i] + " " + summaries[i] + " " + ratings[i];

}

// Adding last line to htmlCode variable

htmlCode += "<br>The other image";

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

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

User The Moof
by
8.2k points