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

javascript input prompt example

const firstName = prompt("Siapa nama depanmu?");
const lastName = prompt("Siapa nama belakangmu?");
const language = prompt("Bisa berbahasa apa?");
 
const user = {
   name: {
       first: firstName,
       last: lastName,
   },
   language: language
};
 
if (user.language === "English") {
   alert("Nice to meet you " + user.name.first + " " + user.name.last + "!");
} else if (user.language === "French") {
   alert("Ravi de vous rencontrer " + user.name.first + " " + user.name.last + "!");
} else if (user.language === "Japanese") {
   alert("Hajimemashite, " + user.name.first + " " + user.name.last + "!");
} else {
   alert("Senang bertemu dengan Anda " + user.name.first + " " + user.name.last + "!");
}
Comment

prompt command in javascript

prompt("Enter your UserName");
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 :: date difference without weekends using moment js 
Javascript :: Kendo Grid export to Excel not working with large data 
Javascript :: prop type for component react js 
Javascript :: change node bash root 
Javascript :: js closure 
Javascript :: scroll div horizontally with move wheel js 
Javascript :: Assume that x is a char variable has been declared and already given a value. Write an expression whose value is true if and only if x is a upper-case letter. 
Javascript :: this keyword in javascript 
Javascript :: json date serialize 
Javascript :: how to extract strings in array js 
Javascript :: how to get the value of AutoCompelet Component in MUI 
Javascript :: download string as file express js 
Javascript :: hook usePreloadImages 
Javascript :: enable emmet in vscode for jsx 
Javascript :: JSON requests using API in Javascript 
Javascript :: Angular p-dialog 
Javascript :: Regex for number divisible by 5 
Javascript :: await vuex dispatch true 
Javascript :: pass arguments into require javascript 
Javascript :: createElement calls with JSX 
Javascript :: sequelize update index column 
Javascript :: find option values using javascript 
Javascript :: how to filter multiple values from a json api 
Javascript :: import slider material ui 
Javascript :: react sticky hook 
Javascript :: javascript append list to list 
Javascript :: news api react native 
Javascript :: javascript sort array 
Javascript :: js promisify function 
Javascript :: jade cdn 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =