Complete the code to import the writable store from Svelte.
import { [1] } from 'svelte/store';
The writable function creates a store that can be updated and subscribed to.
Complete the code to create a writable store with initial value 0.
const count = [1](0);
The writable function creates a store that holds a value and can be updated.
Fix the error in the code to subscribe to the store and log its value.
count.[1](value => console.log(value));The subscribe method listens for changes and runs the callback with the current value.
Fill both blanks to update the store value by adding 1.
count.[1](n => n [2] 1);
The update method takes a function to change the current value. Adding 1 increases the count.
Fill all three blanks to create a derived store that doubles the count value.
import { derived } from 'svelte/store'; const double = derived(count, [1] => [2] * 2); // To get the value use double.[3](v => console.log(v));
The derived store uses a function with parameter n (the count value) and returns n * 2. To listen to changes, use subscribe.