Complete the code to display the value of name inside the template.
<script> let name = 'Alice'; </script> <h1>Hello, [1]!</h1>
In Svelte, you use curly braces {} to insert dynamic values inside the template.
Complete the code to update the displayed count when the button is clicked.
<script> let count = 0; function increment() { count[1]; } </script> <button on:click={increment}>Add</button> <p>Count: {count}</p>
-- which decreases the value.= without adding anything.+= without a number.The ++ operator increases the value by 1, which updates the reactive variable count.
Fix the error in the reactive statement to update double when count changes.
<script> let count = 1; $: double = count [1] 2; </script> <p>Double: {double}</p>
The * operator multiplies count by 2 to get double.
Fill both blanks to create a reactive statement that updates message when name changes.
<script> let name = 'Bob'; $: message = [1] + ' is learning Svelte!'; </script> <p>{message}</p>
count or message.The variable name is used to build the message dynamically.
Fill all three blanks to create a reactive statement that updates greeting using hour and name.
<script> let hour = 10; let name = 'Eve'; $: greeting = (hour [1] 12) ? 'Good morning, ' + [2] : 'Good evening, ' + [3]; </script> <p>{greeting}</p>
name.toUpperCase() which changes the name's appearance.The condition checks if hour is less than 12 to say good morning. The name variable is used to greet the person.