Complete the code to update the array reactively in Svelte.
let items = [1, 2, 3]; function addItem() { items = [...items, [1]]; }
In Svelte, to update an array reactively, you create a new array with the new item. Using items = [...items, 4] triggers reactivity.
Complete the code to update an object property reactively in Svelte.
let user = { name: 'Alice', age: 25 };
function updateAge() {
user = { ...user, [1] };
}To update an object reactively in Svelte, create a new object with the updated property using spread syntax.
Fix the error in the code to make the array update reactive in Svelte.
let numbers = [1, 2, 3]; function addNumber() { numbers.push(4); [1]; }
After pushing to the array, reassigning it with a new array copy triggers Svelte's reactivity.
Fill both blanks to create a reactive filtered array in Svelte.
let allItems = [1, 2, 3, 4, 5]; $: filtered = allItems.[1](item => item [2] 3);
Using filter with a condition item > 3 creates a reactive filtered array.
Fill all three blanks to create a reactive object property update in Svelte.
let settings = { theme: 'light', fontSize: 14 };
function increaseFont() {
settings = { ...settings, [1]: settings.[2] + [3] };
}To update the fontSize reactively, spread the old settings and set fontSize to its current value plus 1.