Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript prompt

// window.prompt() => Prompt for user input and return the value:
const person = prompt("Please enter your name");

console.log( "Hello " + person + " !" );

// The 2nd argument (optional) holds the default value:
const color = prompt("Enter a color name", "red");
Comment

js window.prompt

// window.prompt(message);
/*
`window.prompt` opens a confirmation dialog with an "Ok"
and "Cancel" button. Upon receiving input, the dialog is
closed and a boolean is returned. `window.prompt` returns
the input string if the "Ok" button was pressed or null
if "Cancel" was pressed.
*/

const user_input = window.prompt("Hello, what language do you code in?");

if (user_input && user_input.trim()) {
	window.alert(user_input + "! Cool!");
} else {
	window.alert("Oh no! You don't seem to have written anything...");
}
/*
Note that this will pause code execution until the
dialog receives input.
*/
Comment

prompt in javascript

let text = prompt("What's your name?");
if (text !== "") {
  alert(`Your name is: ${text}`);
} else {
  alert(`Name cannot be empty`)
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: js if text contains lowercase 
Javascript :: react native material bottom tabs 
Javascript :: discord.js messageUpdate 
Javascript :: javascript mutation observer 
Javascript :: add/cart shopify api 
Javascript :: what is a block in javascript 
Javascript :: randomize an array 
Javascript :: date picker type react 
Javascript :: add navbar active 
Javascript :: react useEffect life cycle 
Javascript :: afficher une variable dans la console javascript 
Javascript :: angularjs make post request 
Javascript :: make table responsive react-bootstrap-table2 
Javascript :: no internet connection html page 
Javascript :: add font awesome with nextjs 
Javascript :: linking open app settings 
Javascript :: 10 javascript interview questions 
Javascript :: string length js 
Javascript :: create a customer in stripe node.js 
Javascript :: vs code jsconfig 
Javascript :: iterate over json data javascript 
Javascript :: bind in javascript 
Javascript :: take string until react 
Javascript :: Return a Sorted Array Without Changing the Original Array 
Javascript :: how to remove last character from string in javascript 
Javascript :: javascript detect back space 
Javascript :: how to get form all filed with properties in jquery 
Javascript :: create relationship between schema in sanity 
Javascript :: copy js object 
Javascript :: jquery embeded by console 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =