> For the complete documentation index, see [llms.txt](https://dhrubo.gitbook.io/programming-with-js/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dhrubo.gitbook.io/programming-with-js/basic-syntax/basic-input-output.md).

# 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:

```javascript
let name = prompt("What is your name?");
console.log("Hello, " + name + "!");
```

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:

```javascript
javascriptCopy codelet x = 5;
console.log("The value of x is " + x);
```

This will output "The value of x is 5" to the console.
