Complete the code to create a writable store in Svelte.
import { [1] } from 'svelte/store'; const count = [1](0);
The writable function creates a store that can be updated and subscribed to.
Complete the code to set a context value in a Svelte component.
import { setContext } from 'svelte'; setContext('[1]', 42);
The first argument to setContext is a key string used to identify the context value.
Fix the error in this Svelte code to get a context value.
import { getContext } from 'svelte'; const value = getContext([1]);
The key passed to getContext must be the same string or symbol used in setContext.
Fill both blanks to create a derived store from a writable store.
import { writable, [1] } from 'svelte/store'; const count = writable(1); const doubled = [2](count, n => n * 2);
The derived function creates a store based on other stores, here doubling the count.
Fill all three blanks to use a store value inside a Svelte component with reactive syntax.
<script> import { [1] } from 'svelte/store'; import { count } from './stores.js'; $: doubled = $[2] * 2; function increment() { [3].update(n => n + 1); } </script>
Import writable to create stores, use $count to access the store value reactively, and call count.update to change it.