| Level Navigation: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18⚡ | 19 |
User Story: As a player, I want the stats bar color to change as my score increases so that I get visual feedback on my progress.
Create dynamic styling that changes the stats bar color based on the current score.
statsStyle object with initial backgroundColor and color propertiesstatsStyle object to the stats div using the style attributeSuggested Color Scheme (feel free to customize):
brown background, whitesmoke textdarkGreen background, whitesmoke textnavy background, whitesmoke textblack background, pink textOther color ideas: purple, teal, crimson, goldenrod, indigo, coral, forestgreen
Why modify objects before rendering? In React, you can create style objects and modify them based on state before the return statement. Each time state changes, the component re-renders and the conditionals run again, creating fresh style objects.