Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

javascript

How to get user input using prompts in JavaScript

Amara Metu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The JavaScript user input

The user input in JavaScript is a method used to request input data. In layman’s terms, it is like a fruit basket that is used to collect fruit from the farm and later process for storage.

Once data is received and “Enter” is pressed, the data is returned. Otherwise, it returns null.

Syntax

prompt(data)

Code

Explanation

Line 1: We prompt the user with a pop-up to enter their name.

Lines 3–6: We print a statement to the screen, welcoming the user by name.

RELATED TAGS

javascript

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring