Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 10 Chapter 11 Chapter 12 Chapter 13 Chapter 14
Chapter 5

Errors & Popup Boxes

The three types of errors and the three popup dialogs.


JavaScript Errors

TypeDescription
Load-time errorsSyntax errors that prevent the script from loading (missing brackets, typos).
Run-time errorsErrors during execution — undefined variables, calling non-functions, division by zero.
Logic errorsCode runs fine but produces wrong results. Hardest to detect — use console.log() to debug.

Popup Box Types

MethodBehaviour
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