I was learning about DOM manipulation and have an HTML document.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <h1 class="test"> Title </h1> <h2 class="test"> Here is the list of all the programming languages: </h2> <ul> <li>JavaScript</li> <li>Python</li> <li>Go</li> </ul> <script> const test = document.getElementsByClassName('test'); test.forEach(item => { console.log(item); }); </script> </body> </html> I have tried accessing the html elements using forEach method but it gives error saying that test.forEach is not a function.