🔎 What you'll see
Uncaught ReferenceError: myFunction is not defined
🤔 Why it happens
JavaScript can't find a variable or function with that name. Usual suspects: a typo, different capitalization, scripts loading in the wrong order, or a function trapped inside another block.
🛠️ How to fix it
- Compare the spelling and capitalization of the name exactly.
- If you use a library (e.g. jQuery, Chart.js), make sure its <script> tag loads before your own code.
- Functions created inside a type="module" script can't be called straight from onclick="..." in your HTML. Switch to addEventListener.
- Check that the function isn't declared inside another function or an if block.
🤖 What to ask your AI
Replace the parts in [ ] with your own details, then paste it in.
I'm getting this error: [error]. The name is created [where] and used [where]. Here's my full HTML/JS code: [code]. Tell me the cause and give me the fixed code.
Other errors
CORS errorThe browser blocks your page from fetching data from another site404 Not FoundThe address or file can't be foundundefined / Cannot read properties of undefinedReading a property of a value that isn't thereSyntaxErrorBrackets or quotes don't match upExposed API keyYou put a secret key in your code or on GitHubMixed ContentAn https page loads something from an http addressBlank white pageYou deployed it and all you see is a blank screenis not a functionCalling something that isn't a functionUnexpected token < in JSONYou expected JSON but got HTMLCannot use import statement outside a moduleThe browser won't accept your import statementfavicon.ico 404The console shows a 404 for favicon.icoData disappears when I refreshYour to-dos or scores aren't being savedPage looks broken or tiny on phonesFine on a computer, weird on mobilegit push rejectedA "rejected" / non-fast-forward errornpm: command not foundYour terminal says npm or node doesn't existPort 3000 is already in useYour dev server says the port is takenEnvironment variables (.env) aren't loadingYou put your API key in .env but it comes out undefinedThe AI keeps failing to fix the same errorYou ask for a fix and nothing changes