Question: Hands on Project 5 Chapter 5 1. In JavaScript, declare a variable named list that contains a reference to the only ul element in the
Hands on Project 5 Chapter 5
1. In JavaScript, declare a variable named list that contains a reference to the only ul element in the document. Also declare empty variables named headingText and TOCEntry.
2. Below the variable declarations, create a for statement that sets a counter variable =1, repeats the loop as long as counter is <10 and increments the counter by 1 each time.
3. within the loop add statements that
a. set the value of headingText variable to the content of the element with an id value equal to the current value of the counter variable
b. create a new li element, and assign it as the value of the TOCEntry variable
c.set the content of the TOCEntry node to the following ("" + headingText + "")
d. add the TOCEntry node as the last child of the list node
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
