Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Basics (Retired) Making Decisions with Conditional Statements The Conditional Challenge Solution

Shalee Woody
Shalee Woody
3,956 Points

Color changes

I tried to change the background color in CSS, but the JS runs first before the background changes color, why?

https://teamtreehouse.com/library/javascript-basics/making-decisions-with-conditional-statements/the-conditional-challenge-solution

Please post your code

1 Answer

Steven Parker
Steven Parker
231,275 Points

You may be misinterpreting the results.

The CSS should take effect first, but the JavaScript will then run and any changes it makes will be the ones reflected in the rendered document. So any changes made by the CSS will be lost if the same things are also changed by the JavaScript code.

For a more thorough analysis be sure to post your (properly formatted) code or provide a link to a workspace snapshot.