i'm very new to JS so be nice haha, but i'm trying to create a table of contents on a page using the DOM.
const h2 = document.querySelectorAll('h2');
const toc = document.querySelector('#toc')
h2.forEach(heading => {
toc.innerHTML = `<li><a href="">${heading}</a></li>`
})
it's not working how i would expect tbh. any help is appreaciated, i'm probably just being dumb