🚗🏍️ Welcome to Motoshare!

Turning Idle Vehicles into Shared Rides & New Earnings.
Why let your bike or car sit idle when it can earn for you and move someone else forward?

From Idle to Income. From Parked to Purpose.
Earn by Sharing, Ride by Renting.
Where Owners Earn, Riders Move.
Owners Earn. Riders Move. Motoshare Connects.

With Motoshare, every parked vehicle finds a purpose. Partners earn. Renters ride. Everyone wins.

Start Your Journey with Motoshare

How to use Prompt function in JavaScript ? with proper example

JavaScript

here is how to use the prompt() function in JavaScript:

The prompt() function is a built-in JavaScript function that displays a dialog box that prompts the user for input. The function takes two arguments:

  • The first argument is a string that contains the message to display to the user.
  • The second argument is a string that contains the default value to display in the text input field.

The function returns a string containing the text that the user entered, or null if the user clicked the Cancel button.

Here is an example of how to use the prompt() function:

JavaScript

let name = prompt("What is your name?");

console.log("Your name is: " + name);

Use code with caution. Learn morecontent_copy

This code will display a dialog box that prompts the user for their name. The default value in the text input field will be empty. When the user clicks the OK button, the function will return the user’s name as a string. The code will then log the user’s name to the console.

OutPut:

0 0 votes
Article Rating
Subscribe
Notify of
guest
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
trackback

[…] How to use Prompt function in JavaScript ? with proper example […]

trackback

[…] How to use Prompt function in JavaScript ? with proper example […]

2
0
Would love your thoughts, please comment.x
()
x