Use @if and @else to Add Logic To Your Styles.......I did?

Tell us what’s happening:
What’s wrong with code ? It won’t pass the last test ?

Your code so far


<style type='text/sass'>
  @mixin border-stroke($val){
    @if $val == light {
      border: 1px solid black;
    } 
    @else if $val == medium {
      border: 3px solid black;
    } 
    @else if $val == heavy {
      border: 6px solid black;
    } 
    @else $val == none {
      border: none;
    } 
  
  
  }
  
  
  #box {
    width: 150px;
    height: 150px;
    background-color: red;
    @include border-stroke(heavy);
  }  
</style>

<div id="box"></div>



Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/sass/use-if-and-else-to-add-logic-to-your-styles

    @else $val == none {
      border: none;
    } 

Here you have a condition ($val == none) without an if. An else without an if is meant to be a fallthrough case and cannot have a condition.

2 Likes

Oh yeah, that was the mistake. It worked. Just became a little over exited :grinning:

It happens to us all. I’m glad I could help. Happy coding!