+ 1

Problem with Javascript

Hi In this little code, i need to recover the value of prompt in a variable. prompt("put a calcule"); let a = prompt() Please help

1st Dec 2024, 12:44 PM
Nickels (formerly Hi"-")
Nickels (formerly Hi"-") - avatar
4 odpowiedzi
+ 6
Hi"-" , You can directly use prompt() to a variable as prompt displays a dialog box to input value from user with optional message . 👇🏻 For Example : let a = prompt("put a calcule "); alert(a); you can alert or print the value of variable on the screen
1st Dec 2024, 12:46 PM
Suparna Das
Suparna Das - avatar
+ 6
Hi"-" To retrieve the value from the prompt dialog and store it in a variable, you need to assign the result of prompt() to a variable Example: let a = prompt("Put a calculation:"); console.log(a); // This will display the entered value in the console.
1st Dec 2024, 12:47 PM
Coder Kay
Coder Kay - avatar
+ 3
Ok thanks
1st Dec 2024, 12:58 PM
Nickels (formerly Hi"-")
Nickels (formerly Hi"-") - avatar
+ 1
Hi"-" You're welcome! 😊
1st Dec 2024, 12:59 PM
Coder Kay
Coder Kay - avatar