This solution is generated by ChatGPT, correctness is not guaranteed. You might also be able to find a solution fromcommunity posts.
AI solution for JavaScript Coding Question on BFE.dev
68. get DOM tags
function getTags() { let tags = []; let domTree = document.getElementsByTagName("*"); for (let i = 0; i < domTree.length; i++) { let tag = domTree[i].tagName.toLowerCase(); if (!tags.includes(tag)) { tags.push(tag); } } return tags; }
//Example usage: console.log(getTags()); //['html', 'head', 'title', 'body', 'div', 'p', 'a', 'img', 'ul', 'li']