SASS Help (@if @else)

Tell us what’s happening:
I literally have no clue why this isn’t working

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 {
    border: none;
  }
}
  
  
  #box {
    width: 150px;
    height: 150px;
    background-color: red;
    @include border-stroke(medium);
  }  
</style>

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0 Safari/605.1.15.

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

Why do you have commas there? I think that’s the problem.

Geez, thanks! I’ve been so used to writing JS functions it was a habit.

1 Like