Hi, I copied this example off of a textbook to test if I actually know how to add scripts to the documents. and apparently I don’t!
I have checked the syntax many times, but cannot find the errors. and I tried to use script tag directly in the html document instead,still nothing written in the script would display.
Can someone tell me why is the script not run? Thank you!
You’ve got an extra closing curly brace (lines 9 and 10), delete one of them.
edit: was on phone, and as soon as I removed the brace it removed the error, I didn’t run it to check, but what @ArielLeslie said. If you copy pasted stuff directly from a textbook, that would be another possible reason why you have wierd characters.
Your code is full of errors. If you look at the JS section, you’ll see an exclamation mark (indicating that your code has errors):
When you click on it, it will take you to the first error:
It looks like a few of your
:s aren’t actually colons, but another (similar looking) character. This could either be from copy-pasting or if you’re on an Apple device it could be their “smart punctuation”.
A post was split to a new topic: Problem with JS script