Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS Advanced Sass Advanced Directives @each

Wayne Priestley
Wayne Priestley
19,567 Points

Convert 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

Hi 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
Wayne Priestley
19,567 Points

Gloria, your a star :)

I had tried .#{to-lower-case ($name)} and it hadn't worked (i had a space after -case)

Thanks again.

Thanks :) It's my pleasure.