0
0
SASSmarkup~5 mins

Function definition with @function in SASS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
A@function
B@mixin
C@include
D@return
How do you send a value back from a Sass function?
A@yield
B@send
C@output
D@return
Which of these is a valid Sass function parameter list?
A[width, height]
B($width, $height)
C{width, height}
D<width, height>
What will this Sass function return?<br>
@function double($n) { @return $n * 2; }
AThe input number plus 2
BThe input number divided by 2
CThe input number multiplied by 2
DThe input number minus 2
Why use Sass functions instead of CSS variables?
AFunctions can calculate values dynamically
BCSS variables can do math
CFunctions are slower
DCSS variables are deprecated
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.