Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a function named double that takes one parameter n.
SASS
@function double($n) {
@return $n [1] 2;
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using + instead of * will add 2 instead of doubling.
Using / will divide instead of multiply.
✗ Incorrect
The function multiplies the parameter $n by 2 using the * operator.
2fill in blank
mediumComplete the code to call the function double with argument 5.
SASS
$result: double([1]); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the parameter name
n instead of a value.Using the function name
double as argument.✗ Incorrect
To call the function with the number 5, pass 5 as the argument.
3fill in blank
hardFix the error in the function by completing the missing operator to subtract 1 from $x.
SASS
@function decrease($x) {
@return $x [1] 1;
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using + will add 1 instead of subtracting.
Using * or / will multiply or divide instead of subtracting.
✗ Incorrect
The function should subtract 1 from $x, so the operator is -.
4fill in blank
hardFill the blank to create a function scale that multiplies $value by $factor.
SASS
@function scale($value, $factor) {
@return $value [1] $factor;
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using + or - will add or subtract instead of multiplying.
Using / will divide instead of multiply.
✗ Incorrect
The function multiplies $value by $factor using the * operator.
5fill in blank
hardFill both blanks to create a function adjust that adds $offset to $base and then divides by $divider.
SASS
@function adjust($base, $offset, $divider) {
@return ($base [1] $offset) [2] $divider;
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using - instead of + for addition.
Using * instead of / for division.
✗ Incorrect
The function adds $offset to $base using +, then divides the result by $divider using /.