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

Tim Ruby
PLUS
Tim Ruby
Courses Plus Student 19,038 Points

Sass Final Exercise 6 of 6

I cannot find an answer, and I am not sure if I am overlooking something, or just making a stupid mistake. I am kinda to the point of giving up on it for a bit. Any feedback would be great.

@mixin rainbow($colors...) {
  @each $color in $colors {
    .#{$color} {
      background: $colors;
    }
  }
}

@include rainbow(red, orange, yellow, green);

2 Answers

Tom Bedford
Tom Bedford
15,645 Points

Check this thread.

I don't think your background is meant to be red, orange, yellow, and green at the same time.

hint: $colors outputs every color not just one.

Mårten Björk
Mårten Björk
3,776 Points

Like Tom says, in background: $colors; you're referring to all the colors at the same time. Instead you want to use the $color (singular) variable, like background: $color;. The $color variable changes for each iteration of the loop, which means that it will print different colors each time – that's the result you're looking for.