Languages
[Edit]
EN

JavaScript - prompt function

0 points
Created by:
Inayah-Alexander
767

This article will show you how to use the prompt functions in JavaScript.

The prompt() method displays a  built-in dialog box that prompts you to enter data.

JavaScript - prompt function
built-in prompt dialog box with - JavaScript

Syntax

result = prompt(title, [defaultValue]);

 

Practical example

// ONLINE-RUNNER:browser;

const name = prompt("What's your name", 'Jacob');
console.log('Your name is ' + name);
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

JavaScript tutorial

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join