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

Kabolobari Benakole
PLUS
Kabolobari Benakole
Courses Plus Student 14,278 Points

Unable to Solve

Can you solve this challenge without touching (reformating) the $teams list? I mean in the teacher's example it was easy - two space-delimited items so the each directive with one added-in variable matched things easily. But now you got 4 items in each list - it's confusing how to solve it.

style.scss
$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);
    }
  }
}

1 Answer

Kabolobari Benakole
PLUS
Kabolobari Benakole
Courses Plus Student 14,278 Points

I actually solved it. Here's what I heard in the review video and it nailed it for me:

So, this is actually a really, really cool example of being able to go through a list iteratively, and then depending on how many values are inside of each object within that list, then you can assign individual variable names to each part of it.

$teams:
  (GreenBay Packers green yellow)
  (Seattle Seahawks blue green)
  (Chicago Bears blue orange)
;

@each $a, $b, $c, $d, $team in $teams {
  .#{to-lower-case($a)} {
    background-color: $c;
    border: 1px solid $d;
    &:after {
      content: 'Your' + ' ' + $a + ' ' + $b;
      color: $d;
    }
  }
}