Question: Consider the following given JavaScript statements: var colors = [ mauve , periwinkle , silver , cherry , lemon ]; var target = document .querySelector(

Consider the following given JavaScript statements: var colors = ["mauve", "periwinkle", "silver", "cherry", "lemon"]; var target = document.querySelector("ul");

Provide the JavaScript code to loop through the array and create a new "li" element containing each element, then insert the newly created "li" element to the target element.

Note: You must use only the built-in DOM functions to create all nodes and attach them to the DOM tree.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!