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 trialWayne Priestley
19,579 PointsConvert the following @each loop from using the nth()
Hi All,
Need a helping hand with this challenge from Advanced Sass please.
Q. Convert the following @each loop from using the nth() function to using a complex list with assigned variables.
Here is original code:
$teams: (GreenBay Packers green yellow) (Seattle Seahawks blue green) (Chicago Bears blue orange);
@each $team in $teams {
.#{to-lower-case(nth($team, 1))} {
background-color: nth($team, 3);
border: 1px solid nth($team, 4);
&:after {
content: 'Your' + ' ' + nth($team, 1) + ' ' + nth($team, 2);
color: nth($team, 4);
}
}
}
Here is my code:
$teams: (GreenBay Packers green yellow) (Seattle Seahawks blue green) (Chicago Bears blue orange);
@each $name, $named, $color, $border in $teams {
.#{to-lower-case $name} {
background-color: $color;
border: 1px solid $border;
&:after {
content: 'Your' + ' ' + $name + ' ' + $named;
color: $border; /* I have also tried $color here */
}
}
}
I'm getting the reply…
Bummer! The background-color for .greenbay should be green.
Any clues?
Thanx
1 Answer
Gloria Dwomoh
13,116 PointsHi Wayne, I think the problem lies here .#{to-lower-case $name}
the function needs parenthesis .#{to-lower-case($name)} :) Let me know if you still have issues.
Wayne Priestley
19,579 PointsWayne Priestley
19,579 PointsGloria, your a star :)
I had tried
.#{to-lower-case ($name)}
and it hadn't worked (i had a space after-case
)Thanks again.
Gloria Dwomoh
13,116 PointsGloria Dwomoh
13,116 PointsThanks :) It's my pleasure.