Complete the code to declare a reactive variable in Svelte.
let count = [1];In Svelte, you declare reactive variables with let. Initializing count to 0 sets it as a number that can change and trigger UI updates.
Complete the code to update the count reactively when a button is clicked.
<button on:click={() => count [1] 1}>Increment</button>The += operator adds 1 to count each time the button is clicked, triggering Svelte's reactive update.
Fix the error in the reactive statement that doubles the count.
<script> let count = 0; $: doubled = count [1] 2; </script>
The * operator multiplies count by 2 to get doubled. This reactive statement updates doubled whenever count changes.
Fill both blanks to create a reactive statement that updates the message when count changes.
<script> let count = 0; $: message = `Count is [1]` + [2]; </script>
The template literal syntax ${count} inserts the current count value inside the string. Adding '!' appends an exclamation mark to the message.
Fill all three blanks to create a reactive statement that updates doubled and tripled values.
<script> let count = 0; $: doubled = count [1] 2; $: tripled = count [2] 3; $: total = doubled [3] tripled; </script>
Multiply count by 2 and 3 to get doubled and tripled. Then add them to get total. This shows how reactive variables update automatically.