The getElementById function is used in HTML to find an element that has a specific ID within the document. However, in your code, you are not referencing the document object, which is necessary for getElementById to work correctly. The document object represents the current HTML document and is essential for interacting with elements in the DOM (Document Object Model).
To use getElementById properly, you need to ensure that the script where you are using this function is linked to the HTML document. This means that the HTML document should include a reference to the script containing the getElementById call. In this lesson, you probably added a <script> tag in the HTML file to link to your JavaScript code.
For more information you can look related documentation.