0
0
Vueframework~20 mins

Creating a new Vue project - Practice Exercises

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Vue Project Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate
2:00remaining
What is the correct command to create a new Vue 3 project using the official CLI?
You want to start a new Vue 3 project using the Vue CLI. Which command will correctly create the project?
Anpm create vue@latest my-vue-app
Bvue create my-vue-app
Cvue init my-vue-app
Dnpm install vue create my-vue-app
Attempts:
2 left
💡 Hint
The latest Vue CLI uses npm create with the vue@latest package.
component_behavior
intermediate
2:00remaining
What will be the rendered output of the default App.vue in a new Vue 3 project?
After creating a new Vue 3 project, the default App.vue contains a template with a <h1> tag showing "Welcome to Your Vue.js App". What will you see in the browser when you run the project?
Vue
<template>
  <h1>Welcome to Your Vue.js App</h1>
</template>

<script setup>
// no script content
</script>

<style>
h1 {
  color: #42b983;
}
</style>
ANo heading is shown because script is empty
BA green heading that says 'Welcome to Your Vue.js App'
CA plain heading with default black color 'Welcome to Your Vue.js App'
DAn error because script setup is empty
Attempts:
2 left
💡 Hint
Check the style section and the template content.
lifecycle
advanced
2:00remaining
When does the onMounted lifecycle hook run in a Vue 3 component?
You add an onMounted hook inside the setup() function of a Vue 3 component. When exactly does this hook execute?
AAfter the component is mounted to the DOM and visible
BRight after the component is created but before it is added to the DOM
CBefore the component is created
DOnly when the component is destroyed
Attempts:
2 left
💡 Hint
Think about when the component is fully ready and visible.
🔧 Debug
advanced
2:00remaining
Why does this Vue 3 component fail to update the displayed count?
Consider this Vue 3 component code:
import { ref } from 'vue';

export default {
  setup() {
    let count = 0;
    function increment() {
      count++;
    }
    return { count, increment };
  }
}
The template uses {{ count }} and a button calls increment. Why does the displayed count not update when the button is clicked?
ABecause count should be declared with const, not let
BBecause increment function is not returned from setup
CBecause count is a plain variable, not a reactive ref
DBecause the template syntax {{ count }} is invalid
Attempts:
2 left
💡 Hint
Think about Vue's reactivity system and how it tracks changes.
🧠 Conceptual
expert
3:00remaining
What is the main advantage of using Vue 3's Composition API over Options API in a new project?
You are deciding between using the Options API or the Composition API for your new Vue 3 project. What is the key benefit of the Composition API?
AIt requires less code because lifecycle hooks are not needed
BIt automatically improves app performance without code changes
CIt removes the need for templates by using only JavaScript
DIt allows better organization and reuse of logic by grouping related code together
Attempts:
2 left
💡 Hint
Think about how code is structured and reused in larger projects.