Error adding a javascript file

hello, I have a problem, you will see I am creating a web page for a task (I am new to this) and well they ask me to create a page in html (I already did that) and then they asked me to add a separate file to that same html that is from javascript (my problem is formed here) well I create my javascript file then I put a link in my html file , but when writing inside the file javascript I get an error that is parsing error: unexpected token I have tried everything, delete the file and create another change the code and even so I don’t know what to do, if you can explain me how to create a javascript extension for an html file without it coming out the error would be very grateful.

code- Glitch :・゚✧

hi, i dont see any code inside of your js file (extra.js). could you maybe send the line that is causing the error?

Sorry, I just gave up trying to add code to the js file and decided to add the js to the html. I really can’t find a solution to the parsing error error: unexpected token, no matter how you put it, it is always generated when writing to the js file

I’m not seeing any errors in the console, which is strange, but I suspect it might be this line:

<!--Fecha de modificacion-->

That’s an HTML comment - the equivalent javascript comment would be // Fecha de modificacion or /* Fecha de modificacion */. I think that the sort of comments you’re using will work if the script is directly in html, but not if it’s an external script.

weird that I was recently reading about this: html style comments is part of the ecmascript standard now ECMAScript® 2023 Language Specification :scream:

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.