practicebasic
Toggle button
A button that toggles between two states: 'off' and 'on'. Changes color and text based on state. Use the ternary operator for conditional rendering.
Objectives
- 1.Declare isOn state with initial value false
- 2.Display
ONorOFFbased on state - 3.Change background color: green when on, gray when off
- 4.On click, toggle state with setIsOn(!isOn)
your code
Hint
The ternary operator: condition ? valueIfTrue : valueIfFalse
Related concepts
Was this helpful?
Sign in to give feedback
