Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to convert the string to uppercase using the sass:string module.
SASS
@use "sass:string"; $result: string.[1]("hello world");
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Adding parentheses in the function name inside the code.
Using 'uppercase' instead of 'to-upper-case'.
Using 'to-upper' which is not a valid function.
✗ Incorrect
The correct function to convert a string to uppercase in the sass:string module is to-upper-case without parentheses in the name.
2fill in blank
mediumComplete the code to check if the string "Sass" starts with the letter "S".
SASS
@use "sass:string"; $is-start: string.[1]("Sass", "S") == 1;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'begins-with' which is not a valid function.
Using 'start-with' which is not a valid function.
Using 'has-prefix' which is not a sass:string function.
✗ Incorrect
The correct function to check if a string starts with a substring is index in the sass:string module. It returns 1 if the substring starts at position 1.
3fill in blank
hardFix the error in the code to get the length of the string "Sass" using the sass:string module.
SASS
@use "sass:string"; $len: string.[1]("Sass");
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Adding parentheses in the function name.
Using 'len' which is not a sass:string function.
Using 'size' which is not a sass:string function.
✗ Incorrect
The correct function to get the length of a string is length without parentheses in the name.
4fill in blank
hardComplete the code to extract the substring "ass" from "Sass" using the sass:string module.
SASS
@use "sass:string"; $sub: string.[1]("Sass", 2, 4);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'substr' as the function name instead of 'slice'.
Using 'substring' which is not a sass:string function.
Using 'cut' which is not a sass:string function.
✗ Incorrect
The correct function to extract a substring is slice (1-based indices: slice("Sass", 2, 4) extracts "ass").
5fill in blank
hardFill all three blanks to replace all occurrences of "s" with "z" in "sass" using the sass:string module.
SASS
@use "sass:string"; $new-str: string.[1]("sass", "[2]", "[3]", 0, $flags: "i");
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'replace-all' which is not a valid function.
Swapping the letters in the second and third blanks.
Not using the 'i' flag for case-insensitive replacement.
✗ Incorrect
The function to replace all occurrences is replace (with 0 for $count to replace all), replacing 's' with 'z' ignoring case.