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 trialTodd Squitieri
8,001 PointsAm I storing the value properly?
Stuck on yet another challenge:
The last part of this particular challenge asks me to store "morning," in a new variable called $time and then to write if/else statements that will color A tags depending on which value is stored in the $time variable (in this particular example, the values are "morning," "afternoon," and everything else).
The problem is that I keep getting an error message saying that I need to define the variable $time and store the value "morning" into it.
Here's my code:
$time {
content: "morning";
}
@mixin time($time) {
@if $time == morning {
a{
color: red;
}
}
@else if $time == afternoon {
a{
color: blue;
}
}
@else {
a{
color: gray;
}
}
}
It's the first part of this code that's the problem... apparently.
What am I doing wrong here? Any feedback would be great!
Thanks so much in advance!
Sincerely,
Todd S
2 Answers
Robert Richey
Courses Plus Student 16,352 PointsHi Todd,
Assigning a value to a variable in Sass typically looks similar to this:
$variable: value;
resulting in setting $time as follows:
$time: morning;
Also, I was tripped up on this challenge as well because of the use of quotation marks. The challenge says to assign a value of "morning" but it really means (unquoted) morning.
Finally, you'll need to either call your mixin with @include time($time)
or remove the mixin and let the if/else stand on it's own.
Todd Squitieri
8,001 PointsThanks Robert. You've helped me a lot. Problem solved! :) I really appreciate it!
Sincerely,
Todd