Kit Library / Computer Science / Frontend Development

⚡ Topic Learning Kit

JavaScript Popup Boxes: alert, confirm, and prompt

English 16 leveled MCQs 20 flashcards 9 games Free

Shared by a Veda teacher · Generated with Veda AI

⚡ Veda Bites

The whole idea, one bite at a time

Veda Bites are swipeable micro-lessons — each one teaches exactly one idea. Here's a taste from this kit; the app has the full deck.

💡 Key Idea

Three Popup Boxes, Three Jobs

One line of JS, instant user interaction.

JavaScript gives you three built-in popup boxes, each designed for a different kind of user interaction.

↳ Pick the box that matches your intent: inform → alert, decide → confirm, collect → prompt.

📖 Definition

alert(): The Simplest Popup

Just want to say something? Use alert.

↳ alert() is fire-and-forget — it shows text and waits for the user to click OK.

💻 Code Example

confirm(): Getting a Yes or No

Ask the user a question they can only answer two ways.

confirm() returns a boolean — `true` if the user clicks OK, `false` if they click Cancel.

↳ Always store confirm()'s return value in a variable — it's your true/false decision.

📖 Smart notes

What you'll study, topic by topic

1

JavaScript Popup Boxes: alert, confirm, and prompt

JavaScript provides three built-in browser popup boxes — alert(), confirm(), and prompt() — that let a webpage display messages, ask for confirmation, or collect user input. Each box blocks the page until the user respon...

  • JavaScript provides three built-in pop-up boxes: `alert()`, `confirm()` and `prompt()`.
  • All three are methods of the global `window` object, so the `window.` prefix is optional.
  • `alert(message)` displays information with a single OK button and returns `undefined`.

~15 min · full explanation, examples & memory tricks in the app

❓ Leveled MCQ practice

Try the smart MCQs from this kit

16 questions laddered from warm-up to topper-level, each with an explanation. A taste:

Which built-in JavaScript function shows a message with a single OK button and returns `undefined`?

Beginner
A `alert()` B `confirm()` C `console.log()` D `prompt()`
Show answer & explanation

`alert()`

`alert(message)` is pure output: it displays information with one OK button and returns `undefined`. `confirm()` returns a boolean and `prompt()` returns a string or `null`.

A script calls `confirm("Delete this file?")` and the user clicks Cancel. What is the return value?

Beginner
A `undefined` B `true` C `false` D `null`
Show answer & explanation

`false`

`confirm()` returns a boolean: `true` for OK and `false` for Cancel. `null` belongs to `prompt()` when the user cancels.

Which of these is NOT a built-in JavaScript pop-up box?

Beginner
A `confirm()` B `modal()` C `alert()` D `prompt()`
Show answer & explanation

`modal()`

JavaScript exposes exactly three built-in dialogs: `alert()`, `confirm()` and `prompt()`. There is no built-in `modal()` function — custom modals must be built with HTML, CSS and JavaScript.

Which pop-up box allows the user to type a value?

Beginner
A `alert()` B `confirm()` C `window.alert()` D `prompt()`
Show answer & explanation

`prompt()`

Only `prompt()` collects typed input. `alert()` and `confirm()` display a message and buttons but give the user no text field.

🃏 Flashcards

Tap a card to flip it

20 flashcards in this kit — the app reviews them with spaced repetition so the right card returns on the right day.

🎮 Learning games

Play your way through this kit

Every game is built from this kit's own content — scores feed your mastery, so playing counts as studying.

Word Match True False Memory Match Flashcard Battle Speed Quiz Guess Term Sequence Builder Categorization Revision Battle Playable in the app

Study it properly — free, in the app

The full Veda Bites deck, complete notes, spaced-repetition flashcards, leveled MCQs, tests and games for this kit — plus Daily Facts and the Arena, every day.