Errors & Popup Boxes
The three types of errors and the three popup dialogs.
JavaScript Errors
| Type | Description |
|---|---|
| Load-time errors | Syntax errors that prevent the script from loading (missing brackets, typos). |
| Run-time errors | Errors during execution — undefined variables, calling non-functions, division by zero. |
| Logic errors | Code runs fine but produces wrong results. Hardest to detect — use console.log() to debug. |
Popup Box Types
| Method | Behaviour |
|---|---|
alert("message") | Displays a message. The user must click OK. |
confirm("Message") | The user chooses OK (true) or Cancel (false). |
prompt("Message", "Default") | The user enters a value in a text field. |
alert("message");
var ok = confirm("Message"); // true or false
var name = prompt("Your name?", "Default");
Chapter 5 Topics
Origin · Overview · Syntax · Variables · Operators · Functions · Events · Dates · Arrays · Conditionals · Loops · Errors · Popups.
Activity — complete the code
Complete the code correctly to mark this lesson as complete automatically.
Complete the popup boxes and error types.
// Popup boxes("message"); // user clicks OK("Message"); // OK (true) or Cancel (false)("Message", "Default"); // user enters a value// Error types// Load-time: errors that stop the script loading// Run-time: errors during