Prompt Input (Additional)
Prompt
Let me introduce you to the new Object in javascript i.e. prompt(" ")
It is Used to Take input from the user, for example you want to take the name as input and print the Hello personName, to do this you have to use prompt
Syntax
Example:
Explanation :
First We have declared a new variable name and have used prompt function to take input from the user.
Then we are printing that name in the console tab.
If you are taking Numbers as the input in variable, then to consider it as a number you have to use parseInt function to convert var to Number
Example (Incorrect)
Example (Correct)
Here,
i have use parseInt function so input number will be considered as a number.