Search⌘ K
AI Features

React to the User

Explore how to interact with users by capturing their input with JavaScript's prompt function. Learn to personalize web pages by combining strings and variables and displaying messages either via alert pop-ups or directly on the page. This lesson helps you apply basic DOM manipulation and string operations to make your pages responsive to user input.

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. ...