Quiz Space

Modern Application Development II · Quiz 2 · 3 Aug 2025 · May 2025 term

Question 10: Consider the following Vue 2 code with Vuex 3 used via C…

Question 10

+3 marksOne or more correct options

Consider the following Vue 2 code with Vuex 3 used via CDN, assume the Vuex store is correctly injected into the Vue instance.

Filename: store.js

javascript
export default store = new Vuex.Store({
state: {
score: 10,
},
mutations: {
increaseScore(state) {
state.score += 5;
},
},
actions: {
increaseScoreAsync({ commit }) {
setTimeout(() => {
commit("increaseScore");
}, 1000);
},
},
});

Filename: score-display.js

javascript
export default Vue.component('score-display', {
template: `
<div>
<p>Current Score: {{ score }}</p>
<button @click="boostNow">Boost Now</button>
<button @click="boostLater">Boost After 1s</button>
</div>
`,
computed: {
score() {
// CODE 1
}
},
methods: {
boostNow() {
// CODE 2
},
boostLater() {
// CODE 3
}
}
});

Which of the following correctly fills in CODE 1, CODE 2, and CODE 3 for the score to be displayed and for the boostNow() and boostLater() methods to work correctly?

Select all that apply.

  1. A
  2. B
  3. C
  4. D
  5. E
Show answer

Correct answers

  • A
  • C
  • D

Question 10 of 16 in the IIT Madras BS Modern Application Development II (MAD 2) Quiz 2 paper sat on 3 Aug 2025, in the May 2025 term (IIT M DIPLOMA AN EXAM QDD2 03 Aug 2025). It carries 3 marks.

More questions from this paper

  1. Q1Suppose a client wants to make a POST request using the Fetch API to a public endpoint at /api/submit, which includes s…
  2. Q2Which of the following statements are true?
  3. Q3Which of the following statement(s) about Web Storage APIs is/are correct?
  4. Q4Which of the following statement(s) is/are true regarding Single Page Applications (SPA) and Progressive Web Apps (PWA)?
  5. Q5Consider the following code snippet. What will be logged to the console?
  6. Q6The following code is using Vue 2 and Vue router 3 running on http://127.0.0.1:5500. Filename: index.html Filename: rou…
  7. Q7Consider the following Vue 2 component defined using the CDN version: Filename: index.html Filename: app.js What will b…
  8. Q8Consider the following JavaScript program: What will be the output of the above program when executed?
  9. Q9Consider the following Vue application with markup "index.html" and JavaScript file "app.js". Filename: index.html File…
  10. Q11Filename: app.js Suppose the application is running on "http://localhost:3000", select the correct option(s)?
  11. Q12The following code is using Vue 2 and Vue router 3 running on http://127.0.0.1:5500. Filename: index.html Filename: rou…
  12. Q13Consider the following Vue application with markup "index.html" and JavaScript file "app.js". Filename: index.html File…
  13. Q14Consider the following Vuex store setup for a user management system: What will happen when the following sequence of o…
  14. Q15You are given the following HTML and JavaScript code that uses Vue 2 via CDN along with Vue Router. Read the code caref…
  15. Q16Suppose the button is clicked multiple times quickly, the message area flickers unexpectedly. How can you improve the c…