Intermediate
Accent colour and dark mode
Finish two functions. The button wiring is already written (you'll learn events properly in Phase 9).
1. setAccent(color) sets the CSS custom property --accent on the <html> element, so the Buy button changes colour.
2. toggleDark() toggles the class dark on <body>, sets the toggle button's text to Light mode when dark is on and Dark mode when it's off, and returns true if dark mode is now on, false if not.
What Check tests
- The Buy button starts teal
setAccent("rgb(255, 0, 0)")turns the Buy button redtoggleDark()turns dark mode on and returnstrue- Calling it again turns dark mode off and returns
false - Clicking the button switches mode and its text
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.