but the line of code it's referring to is for (let i = 0; i < chars.length; i++) {, which is placed within script tags. I don't understand why it isn't recognizing the JavaScript. Also, I'm coding in Notepad (it's saved as an xhtml document), and the browser is Chrome if that is relevant.
I've been having some other problems as well, like not being able to link in CSS, or include elements such as meta in the head section; the webpage comes out blank.
Everything in an XHTML document is parsed as XML, so when it reaches i < chars, the parser thinks the < is going to start a tag, and throws an error when it doesn't. A HTML parser knows to escape the contents between <script> and </script> tags but an XML parser doesn't.
When using XHTML, the < must be escaped within the JavaScript, either as < or by being placed in a CDATA section.