...

/

Create a Smart Button

Create a Smart Button

Explore how to 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.

Goals

You’ll learn how 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:

JavaScript that thinks

To make the ...