<script> let name = 'Alice'; </script> <h1>Hello {name}!</h1>
The variable name is set to 'Alice' and used inside curly braces in the HTML. Svelte replaces {name} with the variable's value, so it displays 'Hello Alice!'.
Option D uses on:click={increment} which is the correct Svelte syntax for event handlers. Other options have wrong event attribute names or missing braces.
<script> let count = 0; function increment() { count += 1; } </script> <button on:click={increment}>{count}</button>
The initial count is 0. Each click adds 1. After two clicks, count is 2, so the button shows '2'.
<script> let count = 0; function increment() { count = count + 1; } </script> <button on:click=increment>{count}</button>
Svelte event directives require braces {} around the handler, like on:click={increment}. Without braces, on:click=increment treats 'increment' as a string literal, so no handler is attached and clicking does nothing.
const count = 0; and then try to increase count inside a function, what will happen?Variables declared with const cannot be reassigned. Trying to update count causes a runtime error. Svelte requires let for reactive variables.