Question: JAVASCRIPT Hello, I need some help getting my code to populate a web page. Any help would be great. Please edit code as needed. CODE

JAVASCRIPT

Hello, I need some help getting my code to populate a web page. Any help would be great.

Please edit code as needed.

CODE

"use strict";

/* JavaScript 7th Edition

Chapter 5

Project 05-03

Project to create a table of headings from an article

Author:

Date:

Filename: Individual Project

*/

let sourceDoc = document.getElementById("source_doc");

let toc = document.getElementById("toc");

let headingCount =1;

const heading = "H2";

for (let n = sourceDoc.firstElementChild; n !== null; n = n.nextElementSibling)

{

if (n.nodeName === heading)

{

let anchor = document.createElement("a");

anchor.name = "doclink" + headingCount;

n.insertBefore(anchor, n.firstElementChild);

let listItem = document.createElement("li");

let link = document.createElement("a");

listItem.appendChild(link);

link.textContent = n.textContent;

link.href = "#" + "doclink" + headingCount;

toc.appendChild(listItem);

headingCount++;

}

}

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!