practicebasic
Like button
A Twitter-style 'like' button: the counter starts at 142 (other users' likes) and you add or subtract 1 on each click.
Objectives
- 1.Declare likes state initial at 142
- 2.Declare isLiked state initial at false
- 3.On click: if isLiked, likes-- and isLiked=false; if not, likes++ and isLiked=true
- 4.Change button color when liked
- 5.Show counter next to button
your code
Hint
Use a numeric state for the total likes (starts at 142, not 0) and a boolean to track whether the current user has liked it
Related concepts
Was this helpful?
Sign in to give feedback
