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 trialChris Warr
12,809 PointsSass Complement Function not Working with My Variable
Hi I have used a variable for my complement function in a similar way as is instructed within video but still get error below.
I have tried complement minus the variable and simply the vale red and it works fine?
Below is my code.
ERROR: Bummer! You need to get the complement of the CSS color red.
/* Write your SCSS code below. */
$red: red; $complement: complement($red);
a { color:lighten($red, 5%); }
5 Answers
Andrew Gray
10,088 PointsIt looks like you are over-thinking things. The task was never to create a variable for red, this adds extra code you don't need and is probably why you aren't passing! To pass task 2 all you need is:
$complement: complement(red);
a {color: lighten(red, 5%)};
Chris Warr
12,809 PointsHI thanks for reply. I included that variable as it states within the panel that is important to include code from previous questions as below. So perhaps best not to have this message on this particular question.
Important: The code you write in each task should be added to the code written in the previous task.
Andrew Gray
10,088 PointsYes, but you could write
$complement: complement(red);
a {color: lighten(red, 5%)};
//Some workings out
/*Some other comment*/
$blue: blue;
$green: green;
$yellow: yellow;
And it would pass, even though the comments and extra variables aren't needed (Copy it and try it if you don't believe me!). You were asked to color <a> tags a lighter red, NOT to create a variable for the color red, so the red variable was extra, needless code that still parsed okay as when converted from Sass to CSS it returned the correct color value.
Also, as long as the code still does what was asked in the previous question you can edit or move it wherever you want. Think of it as a list of requirements that your code is scanned for. Question two wanted you to create a precise variable containing the color value red, NOT another variable containing the color value red. Because this wouldn't be converted into CSS it searched for the $complement variable and checked for this exact string:
$complement: complement(red);
but instead it found:
$complement: complement($variable);
You could have called the $variable anything and set it to red and it wouldn't have worked, it would only accept the value "red".
These questions often seem more complex than they are, just remember to keep it simple and only do what the question asks.
Chris Warr
12,809 PointsThanks thats pretty much what you mentioned earlier. The statement mentions to keep previous code with a varible assigned to red and the conclusion would be to keep using this with subsequent questions. To me it's misleading and cost me 45 mins or so. I thought I would ,make a point of it even tho I did figure this out on my own in case it may save someone else some time.
Andrew Gray
10,088 PointsTo clarify, the questions are:
Open a scope for <a> tags and make their color 5% lighter than the standard red.
Set a variable named $complement to be the complement of the standard red.
Neither question asked you to create a variable for the color red, it wasn't needed, which is what tripped you up. Sorry if I was too long-winded before!
Pablo Grippo
25,765 PointsThis line of code works for me!
$complement: complement(red);