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

CSS Sass Basics (retired) Advanced Sass Concepts Interpolating and if/else

stuck with Sass challenge

I'm stuck at step four of the challenge, I have no clue how to begin this, even after watching the video a couple of times. Can someone enlighten me how this step works?

Underneath the previous code, store the value "morning" in a variable named $time. Then write an if/else directive that will color all <a> tags. If the variable $time is equal to "morning", the color should be red. Otherwise, if the variable is "afternoon", the color should be blue. Finally, if the variable is set to anything else, the color should be gray. Bummer! You need to define a $time variable and set its value to: morning PreviewRecheck work index.html style.scss

/* Write your SCSS code below. */

@mixin cars($make, $color) { .#{$make}{ border: 1px solid black; background-image: url("#{$color}" + ".png"); } }

2 Answers

Rae Yung
Rae Yung
9,113 Points

As I understand it (and I'm a Sass novice myself, so take this with a grain of salt): This basically has nothing to do with the @mixin written in the previous parts of the challenge! That was a little disorienting for me when I went through it.

After defining the variable:

$time: morning

you need to open up an 'a' declaration to contain the if/else part, using the syntax from the video.

a {
    @if ... {
    } @else if ... {
    } @else {
    }
}

From there, you can just slot in the conditionals ($time == morning etc.) and define how they affect the color property using normal CSS within the if/else curly brackets. I hope that helps!

Thx Rae, you helped me along the way. One thing to note though before it works, the defining variable needs to end with ";" for it to work.