---
id: 587d7dbe367417b2b2512bb8
title: Use @if and @else to Add Logic To Your Styles
required:
- src: 'https://cdnjs.cloudflare.com/ajax/libs/sass.js/0.10.9/sass.sync.min.js'
raw: true
challengeType: 0
videoUrl: ''
localeTitle: Use @if y @else para agregar lógica a sus estilos
---
## Description
La directiva @if en Sass es útil para probar un caso específico: funciona igual que la sentencia if en JavaScript. @mixin make-bold ($ bool) {
@if $ bool == true {
font-weight: negrita;
}
}
Y al igual que en JavaScript, @else if y @else prueban más condiciones: @mixin efecto-texto ($ val) {
@if $ val == peligro {
color rojo;
}
@else if $ val == alert {
color amarillo;
}
@else if $ val == éxito {
color verde;
}
@else {
de color negro;
}
}
## Instructions
Cree un mixin llamado border-stroke que tome un parámetro $val . La mixin debe verificar las siguientes condiciones usando @if , @else if , y @else : luz - 1px negro sólido
mediano - 3px negro sólido
pesado - 6px negro sólido
ninguno - sin borde
## Tests
```yml
tests:
- text: Su código debe declarar un mixin denominado border-stroke que tiene un parámetro llamado $val .
testString: 'assert(code.match(/@mixin\s+?border-stroke\s*?\(\s*?\$val\s*?\)\s*?{/gi), "Your code should declare a mixin named border-stroke which has a parameter named $val.");'
- text: Su mixin debe tener una instrucción @if para verificar si $val está claro y para establecer el border en 1px negro sólido.
testString: 'assert(code.match(/@if\s+?\$val\s*?===?\s*?light\s*?{\s*?border\s*?:\s*?1px\s+?solid\s+?black\s*?;\s*?}/gi), "Your mixin should have an @if statement to check if $val is light, and to set the border to 1px solid black.");'
- text: 'Su mixin debe tener una @else if para verificar si $val es medio, y para establecer el border en 3px negro sólido.'
testString: 'assert(code.match(/@else\s+?if\s+?\$val\s*?===?\s*?medium\s*?{\s*?border\s*?:\s*?3px\s+?solid\s+?black\s*?;\s*?}/gi), "Your mixin should have an @else if statement to check if $val is medium, and to set the border to 3px solid black.");'
- text: 'Su mixin debe tener una @else if para verificar si $val es pesado, y para establecer el border en 6px negro sólido.'
testString: 'assert(code.match(/@else\s+?if\s+?\$val\s*?===?\s*?heavy\s*?{\s*?border\s*?:\s*?6px\s+?solid\s+?black\s*?;\s*?}/gi), "Your mixin should have an @else if statement to check if $val is heavy, and to set the border to 6px solid black.");'
- text: Su mixin debe tener una instrucción @else para establecer el border en ninguno.
testString: 'assert(code.match(/@else\s*?{\s*?border\s*?:\s*?none\s*?;\s*?}/gi), "Your mixin should have an @else statement to set the border to none.");'
```
## Challenge Seed
## Solution
```js
// solution required
```