JavaScript, The web warrior serise, Edition Six Q) Hands-On Project 5-5 In this
ID: 3697025 • Letter: J
Question
JavaScript, The web warrior serise, Edition Six
Q) Hands-On Project 5-5
In this project, you’ll create and reference document elements as a means of generating a
table of contents for a document containing the United States Bill of Rights.
. In your text editor, open the index.htm file from the HandsOnProject - folder in the
Chapter folder, add your name and today’s date where indicated in the comment
section, and then save the file.
. Within the body section, just before the closing </body> tag, add a script element.
. Within the script element, 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.
. Below the variable declarations, create a for statement that sets a counter variable
equal to , repeats the loop as long as the value of the counter variable is less than or
equal to , and increments the counter variable by each time through the loop.
. Within the for loop, add statements that perform the following tasks:
a. Set the value of the 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:
"<a href=#" + i + ">" + headingText + "</a>"
d. Add the TOCEntry node as the last child of the list node.
Explanation / Answer
tm.js
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.