React to the User

Let’s make JavaScript feel like a real conversation. In this lesson, you’ll ask the user something using prompt(), and use what they say to update your page or show a message.

Goal

You will 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 this: “Nice to meet you, Ava!?”

Let’s learn how to build full messages by joining strings together. Recall that a string is just text inside quotes, like:

Get hands-on with 1400+ tech skills courses.