4. What is wrong with this Vue template expression?
<div>{{ user.name.toUpperCase }}</div>
Assuming user.name is a string.
medium
A. toUpperCase is not a valid method
B. Cannot use functions inside templates
C. user.name is undefined
D. Missing parentheses to call the function
Solution
Step 1: Identify the method usage error
toUpperCase is a function and must be called with parentheses ().
Step 2: Correct the expression
The correct expression is user.name.toUpperCase() to get the uppercase string.
Final Answer:
Missing parentheses to call the function -> Option D
Quick Check:
Call methods with () inside {{ }} [OK]
Hint: Always add () when calling functions in templates [OK]
Common Mistakes:
Forgetting parentheses on method calls
Trying to use unsupported functions
Assuming properties auto-call functions
5. You want to display a list of numbers doubled inside a Vue template using numbers = [1, 2, 3]. Which expression correctly creates a comma-separated string of doubled numbers?
hard
A. {{ numbers.map(n => n * 2).join(', ') }}
B. {{ numbers * 2 }}
C. {{ numbers.forEach(n => n * 2) }}
D. {{ numbers.map(n => n * 2) }}
Solution
Step 1: Understand array transformation in templates
To double each number, use map with a function n => n * 2.
Step 2: Convert the array to a string
Using join(', ') converts the array to a comma-separated string for display.
Final Answer:
<code>{{ numbers.map(n => n * 2).join(', ') }}</code> -> Option A
Quick Check:
Use map + join for array display [OK]
Hint: Use map() then join() to show transformed arrays [OK]
Common Mistakes:
Trying to multiply array directly
Using forEach which returns undefined
Not joining array to string for display
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.