Use @each to Map Over Items in a List crome not working

Use @each to Map Over Items in a List crome not working
0

#1

Tell us what’s happening:
I dont why it is not working. Is the sass course buggy or am I doing something wrong. Please can some one help me.

Your code so far


<style type='text/sass'>
$colors: (color1: blue, color2: black, color3: red);
@each $key, $color in $colors {
  .#{$color}-text {color: $color; }
}
  

div {
    height: 200px;
    width: 200px;
    background-color: $colors;
  
.blue-bg {
  background-color: $color1;
}

.black-bg {
  background-color: $color2;
}

.red-bg {
  background-color: $color3;
}
</style>

<div class="blue-bg">blue</div>
<div class="black-bg">black</div>
<div class="red-bg">red</div>

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/sass/use-each-to-map-over-items-in-a-list


#2

Try using Chrome instead of the browser you are currently using.


#3

Sorry I am using Chrome. Sass seems to be buggy. Has anyone got any ideas how to fix these problems


#4

Sorry about that. I should have paid more attention to your actual code.

You should not be adding any extra CSS declarations such as what you have below:

.blue-bg {
  background-color: $color1;
}

.black-bg {
  background-color: $color2;
}

.red-bg {
  background-color: $color3;
}

Instead, the goal is to have SASS to create the following CSS:

.blue-bg {
  background-color: blue; }

.black-bg {
  background-color: black; }

.red-bg {
  background-color: red; }

div {
  height: 200px;
  width: 200px; }

Instead your SASS code does not follow any correct syntax you were shown in the example. I suggest reviewing the 1st example (shown below) in the challenge where they generate the text color for each of the the 3 colors specified to create CSS classe names which include the color name followed by “-text”.

@each $color in blue, red, green {
  .#{$color}-text {color: $color;}
}