BananaMaster

47.1 - Battle Scene: Damage, Practice (JS lessons โ€” arguments and return)

If you forgot something โ€” click to go to the lesson.

๐Ÿ“˜ Task: Battle HP Bar

The page shows a character with an HP bar above it. Below the character are 4 attack buttons.

๐Ÿ—๏ธ What you need to prepare in HTML:

โš”๏ธ Battle rules:

๐Ÿ“ How this should work:

Clicking any of the 4 buttons decreases the character's current HP by that button's damage. HP can't go below 0. After every click the HP bar and text on screen update and show the current value.

๐Ÿงช Example:

The character starts the battle with 100 HP. The user clicks the buttons in order:

After these three clicks the screen should show:

25 / 100 HP