Complete the code to define a computed property in Vue.
<script setup> import { ref, [1] } from 'vue' const count = ref(0) const double = [1](() => count.value * 2) </script>
The computed function creates a reactive computed property that updates automatically when its dependencies change.
Complete the code to watch the 'count' ref and log its new value.
<script setup> import { ref, watch } from 'vue' const count = ref(0) watch(count, (newVal) => { console.log([1]) }) </script>
The watcher callback receives the new value as the first argument, commonly named newVal.
Fix the error in the watch usage to correctly watch a nested property.
<script setup> import { reactive, watch } from 'vue' const state = reactive({ user: { name: 'Alice' } }) watch([1], (newName) => { console.log('Name changed to', newName) }) </script>
To watch a nested property in a reactive object, use a getter function like () => state.user.name.
Fill both blanks to create a computed property that depends on 'firstName' and 'lastName'.
<script setup> import { ref, [1] } from 'vue' const firstName = ref('John') const lastName = ref('Doe') const fullName = [2](() => `${firstName.value} ${lastName.value}`) </script>
Both blanks require computed to import and create the computed property.
Fill both blanks to watch 'age' and update 'isAdult' accordingly.
<script setup> import { ref, watch } from 'vue' const age = ref(17) const isAdult = ref(false) watch([1], (newAge) => { isAdult.value = newAge [2] 18 }) </script>
Watch the age ref, compare newAge with 18 using '>=' operator, and assign the result to isAdult.value.