0
0
Vueframework~10 mins

Why state management is needed in Vue - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a reactive state variable in Vue.

Vue
const count = [1](0);
Drag options to blanks, or click blank then click option'
Awatch
Bref
Ccomputed
Dreactive
Attempts:
3 left
💡 Hint
Common Mistakes
Using reactive instead of ref for primitive values.
Using computed when you want a simple reactive variable.
2fill in blank
medium

Complete the code to update the reactive state variable in Vue.

Vue
count[1] = count[1] + 1;
Drag options to blanks, or click blank then click option'
A()
B[0]
C.value
D{}
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to update the ref variable directly without .value.
Using parentheses or brackets instead of .value.
3fill in blank
hard

Fix the error in the code to share state between components using Vue's provide/inject.

Vue
provide('count', [1]);
Drag options to blanks, or click blank then click option'
Areactive(count)
Bref(count)
Ccount.value
Dcount
Attempts:
3 left
💡 Hint
Common Mistakes
Providing count.value instead of count.
Wrapping count again in ref or reactive.
4fill in blank
hard

Fill both blanks to create a computed property that doubles the count.

Vue
const doubleCount = computed(() => count[1] * [2]);
Drag options to blanks, or click blank then click option'
A.value
B2
C3
D.value()
Attempts:
3 left
💡 Hint
Common Mistakes
Using .value() which is not a function.
Multiplying by 3 instead of 2.
5fill in blank
hard

Fill all three blanks to create a reactive object with a name and age, and update age.

Vue
const person = reactive({ name: '[1]', age: [2] });
person.[3] = 30;
Drag options to blanks, or click blank then click option'
AAlice
B25
Cage
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number without quotes for name.
Trying to update the name instead of age.