...

/

React to the User

React to the User

Learn how to use prompt() to get input and respond with logic.

Let’s make JavaScript feel like a real conversation. In this lesson, you’ll ask the user a question using prompt(), then use their response to update the page or display a message.

Goals

You’ll learn to:

  • Get user input with prompt().

  • Display the input in an alert or on the page.

  • Personalize your page using what the user said.


So far, you have learned to show just the name by itself. But what if you want to say something like, ...