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

Errors & Popup Boxes

5 slides · use ←/→ or Space to navigate, F for fullscreen.

Reading view

← Back to the full Chapter 5 deck

Errors & Popup Boxes
Fullscreen for presentation · Print / PDF for a handout
1 / 5
Lesson

Errors & Popup Boxes

The three types of errors and the three popup dialogs.

Errors & Popup Boxes

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.
Errors & Popup Boxes

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");
Errors & Popup Boxes

Chapter 5 Topics

Origin · Overview · Syntax · Variables · Operators · Functions · Events · Dates · Arrays · Conditionals · Loops · Errors · Popups.

Errors & Popup Boxes

Activity — complete the code

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