Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the tick function from Svelte.
Svelte
import { [1] } from 'svelte';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'wait' or 'delay' which are not Svelte functions.
Trying to import from 'svelte/internal' instead of 'svelte'.
✗ Incorrect
The tick function is imported from 'svelte' to wait for the DOM to update.
2fill in blank
mediumComplete the async function to wait for the DOM update using tick.
Svelte
async function update() {
// some state change
await [1]();
console.log('DOM updated');
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to use
await before tick.Using non-existent functions like 'wait' or 'delay'.
✗ Incorrect
Using await tick() pauses the function until Svelte updates the DOM.
3fill in blank
hardFix the error in the code by completing the import statement correctly.
Svelte
import { [1] } from 'svelte';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing tick from 'svelte/internal' which is incorrect.
Using wrong function names like 'update' or 'render'.
✗ Incorrect
The tick function should be imported from 'svelte', not 'svelte/internal'.
4fill in blank
hardFill both blanks to create a function that updates a variable and waits for DOM update.
Svelte
import { [1] } from 'svelte'; async function change() { count = count + 1; await [2](); console.log('Count updated in DOM'); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different words for import and await.
Using non-existent functions like 'update' or 'refresh'.
✗ Incorrect
Both blanks use tick: to import and to wait for DOM update.
5fill in blank
hardFill all three blanks to import tick, update a variable, and wait for DOM update.
Svelte
import { [1] } from 'svelte'; let value = 0; async function increment() { value [2] 1; await [3](); console.log('Value updated:', value); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '++' which is not valid in Svelte reactive assignments.
Forgetting to await tick after updating the variable.
✗ Incorrect
Import tick, use += to add 1, then await tick() to wait for DOM update.