Recall & Review
beginner
What is the purpose of
@function in Sass?@function lets you create reusable blocks of code that return a value. It helps you calculate values dynamically in your stylesheets.
Click to reveal answer
beginner
How do you return a value from a Sass function?
Use the @return keyword followed by the value you want to send back from the function.
Click to reveal answer
beginner
Write a simple Sass function that adds two numbers.
<pre>@function add($a, $b) {
@return $a + $b;
}</pre>Click to reveal answer
beginner
Can Sass functions accept parameters? How?
<p>Yes, Sass functions can accept parameters inside parentheses after the function name, like <code>@function name($param1, $param2)</code>.</p>Click to reveal answer
beginner
Why use Sass functions instead of plain CSS?
<p>Sass functions let you do math and logic to create dynamic styles, saving time and avoiding repetitive code.</p>Click to reveal answer
What keyword starts a function definition in Sass?
✗ Incorrect
@function is used to define a function in Sass.
How do you send a value back from a Sass function?
✗ Incorrect
@return sends the result back from the function.
Which of these is a valid Sass function parameter list?
✗ Incorrect
Sass uses parentheses with dollar sign variables for parameters.
What will this Sass function return?<br>
@function double($n) { @return $n * 2; }✗ Incorrect
The function multiplies the input by 2 and returns it.
Why use Sass functions instead of CSS variables?
✗ Incorrect
Sass functions let you do calculations and logic, which CSS variables alone cannot do.
Explain how to create and use a function in Sass with an example.
Think about how you write a function in programming but for styles.
You got /4 concepts.
Describe the benefits of using Sass functions in your stylesheets.
Why would you want to do math or logic in your styles?
You got /4 concepts.