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 trial

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.