Complete the code to create a reactive variable that updates when count changes.
<script> let count = 0; $: doubled = count [1] 2; </script>
The $: syntax creates a reactive statement. Here, doubled updates automatically when count changes by multiplying it by 2.
Complete the code to create a reactive statement that updates message when name changes.
<script> let name = 'Alice'; $: message = `Hello, $[1]!`; </script>
count.message inside its own definition causing confusion.user which is not declared.The reactive statement uses name inside the template string to update message whenever name changes.
Fix the error in the reactive statement to correctly update total when price or quantity changes.
<script> let price = 5; let quantity = 3; $: total = price [1] quantity; </script>
The total cost is the product of price and quantity, so the multiplication operator * is needed.
Fill both blanks to create a reactive statement that updates fullName by combining firstName and lastName with a space.
<script> let firstName = 'John'; let lastName = 'Doe'; $: fullName = [1] + [2]; </script>
The reactive statement concatenates firstName with a space and then lastName to form fullName.
Fill all three blanks to create a reactive statement that updates summary with the uppercase title, the count, and a check if count is greater than 10.
<script> let title = 'task'; let count = 12; $: summary = `$[1]: $[2] items - $[3]`; </script>
title.toLowerCase() instead of uppercase.count in the string.The reactive statement creates a string showing the uppercase title, the count, and a word indicating if count is many or few based on the condition.