Basic Input/output
In JavaScript, you can use the prompt()
and console.log()
methods for basic input/output.
The prompt()
method displays a dialog box with a message for the user to input data. The user's response is stored in a variable that you can use later in your program.
Here's an example of how to use prompt()
to get a user's name and then display a personalized greeting:
The console.log()
method is used to output data to the console. You can pass any type of data to console.log()
and it will be displayed in the console. Here's an example:
This will output "The value of x is 5" to the console.
Last updated