Command Palette

Search for a command to run...

Hectal
Phase 7: this, Prototypes and Classes
JavaScript · Exercise 1 of 5Next
Beginner

Fix the like button that lost this

The Like button should add one to likes.count and show the new number. Right now clicking it shows NaN, because likes.add loses its this when it's passed to addEventListener.

Fix the last line so every click adds one to likes.count and the page shows the count. Don't change the likes object.

What Check tests

  1. One click shows 1
  2. A second click shows 2
  3. The count is stored on likes, not on the button
  4. No errors

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.