Solution: React to the User
This code asks the user for their favorite color and updates a webpage message to display that color in text and style.
Explanation:
A prompt box appears asking the user to enter their favorite color.
The program then updates the paragraph with ID
"colorMessage"to show the message “You chose: [color]”.Finally, it changes the text color of the paragraph to match the color the user entered (e.g., typing “blue” makes the text blue).
Solution: React to the User
This code asks the user for their favorite color and updates a webpage message to display that color in text and style.
Explanation:
A prompt box appears asking the user to enter their favorite color.
The program then updates the paragraph with ID
"colorMessage"to show the message “You chose: [color]”.Finally, it changes the text color of the paragraph to match the color the user entered (e.g., typing “blue” makes the text blue).