Nearby lessons
26 of 40✍️ JavaScript prompt()
📌 What is JavaScript prompt()?
The prompt() method displays a dialog box that asks the user for input.
Includes a text field and OK/Cancel buttons.
📋 prompt() Basics
| Attribute | Description |
|---|---|
Syntax | prompt(message, default) |
Return | String input or null |
Use Case | Getting user input (e.g., name, age) |
Code Example
PREVIEW READY
🧠 Test Your Knowledge
2 QuestionsProgress: 0 / 2
Keep Going!JS - Functions