0
0
Vueframework~10 mins

JavaScript expressions in templates in Vue - Interactive Code Practice

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

Complete the code to display the value of message inside the template.

Vue
<template>
  <p>{{ [1] }}</p>
</template>
Drag options to blanks, or click blank then click option'
Amsg
Bmessage
Ctext
Dcontent
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name that is not defined in the component.
Forgetting to use double curly braces for interpolation.
2fill in blank
medium

Complete the code to show the length of the items array in the template.

Vue
<template>
  <p>Total items: {{ [1] }}</p>
</template>
Drag options to blanks, or click blank then click option'
Aitems.count
Bitems.size
Citems.length
Ditems.total
Attempts:
3 left
💡 Hint
Common Mistakes
Using count or size which are not valid array properties in JavaScript.
Trying to call length() as a function.
3fill in blank
hard

Fix the error in the template expression to correctly show the uppercase version of name.

Vue
<template>
  <p>{{ name.[1]() }}</p>
</template>
Drag options to blanks, or click blank then click option'
AtoUpperCase
Buppercase
CtoUppercase
DUpperCase
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect capitalization like toUppercase or uppercase.
Forgetting the parentheses to call the method.
4fill in blank
hard

Fill both blanks to create a computed property that returns the doubled value of count.

Vue
<script setup>
import { computed } from 'vue'
const count = ref(5)
const doubleCount = computed(() => count[1][2])
</script>
Drag options to blanks, or click blank then click option'
A*
B+
C2
Dcount
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition instead of multiplication.
Using the variable name count again instead of a number.
5fill in blank
hard

Fill all three blanks to create a template expression that shows the first item in items in uppercase.

Vue
<template>
  <p>{{ items[1] [2] [3]() }}</p>
</template>
Drag options to blanks, or click blank then click option'
A[0]
B.charAt
C.toUpperCase
D.slice
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to access the first item before calling string methods.
Using incorrect method names or missing parentheses.