Create a Smart Button

Trigger different responses based on stored data.

Now that your code can remember things and make decisions, let’s bring it all together! You’ll build a button that changes how it behaves—depending on what the user has already done.

Goal

You will learn to:

  • Use if/else inside an event listener.

  • Respond differently depending on a value.

  • Create dynamic behavior on click.

HTML setup

Let’s start with a simple button and a space to show the message:

Get hands-on with 1400+ tech skills courses.