Challenge - 5 Problems
Svelte Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Why does Svelte compile components at build time?
Svelte compiles components into efficient JavaScript during build time instead of using a virtual DOM at runtime. What is the main benefit of this approach?
Attempts:
2 left
💡 Hint
Think about what happens when less work is done in the browser.
✗ Incorrect
Svelte shifts work from the browser to build time, so the browser runs less code. This leads to faster apps and smaller bundles.
❓ component_behavior
intermediate2:00remaining
How does Svelte update the UI when state changes?
In Svelte, when you update a variable declared with
let inside a component, how does the UI update?Svelte
let count = 0; function increment() { count += 1; }
Attempts:
2 left
💡 Hint
Think about how Svelte knows when a variable changes.
✗ Incorrect
Svelte compiles code so that assignments to let variables trigger DOM updates automatically without extra calls.
❓ lifecycle
advanced2:00remaining
What lifecycle behavior is unique to Svelte compared to React or Vue?
Which lifecycle feature is specific to Svelte's approach and not found in React or Vue?
Attempts:
2 left
💡 Hint
Svelte has lifecycle callbacks named differently than React or Vue.
✗ Incorrect
Svelte provides beforeUpdate which runs just before the DOM updates, a feature not present in React or Vue lifecycles.
📝 Syntax
advanced2:00remaining
What is the correct way to declare a reactive statement in Svelte?
Which option shows the correct syntax for a reactive statement that updates
double when count changes?Svelte
let count = 1; let double;
Attempts:
2 left
💡 Hint
Look for the special symbol Svelte uses for reactive statements.
✗ Incorrect
Svelte uses $: to mark reactive statements that run whenever dependencies change.
🔧 Debug
expert3:00remaining
Why does this Svelte component not update the UI when
count changes?Consider this code snippet:
let count = 0;
function increment() {
count++;
}
The UI shows {count} but does not update when increment is called. Why?Attempts:
2 left
💡 Hint
Think about how Svelte detects changes to variables.
✗ Incorrect
Svelte tracks assignments to variables. Using count++ increments but does not assign, so reactivity is not triggered.