Quiz Space

Modern Application Development II · Quiz 2 · 16 Mar 2025 · January 2025 term

Question 15: Consider the below Vue.js application. What will be the …

Question 15

+4.5 marksOne correct option

Consider the below Vue.js application.

html
<template>
<div>
<button @click="goToPage('Home')">Go to Home</button>
<button @click="goToPage('About')">Go to About</button>
<button @click="goToPage('Contact')">Go to Contact</button>
<div v-if="visitedPages.length">
<h3>Visited Pages:</h3>
<ul>
<li v-for="(page, index) in visitedPages" :key="index">{{ page
}}</li>
</ul>
</div>
</div>
</template>
<script>
export default {
data() {
return {
visitedPages: []
};
},
mounted() {
const storedPages = JSON.parse(sessionStorage.getItem('visitedPages'))
|| [];
this.visitedPages = storedPages;
},
methods: {
goToPage(page) {
this.visitedPages.push(page);
sessionStorage.setItem('visitedPages',
JSON.stringify(this.visitedPages));
this.$router.push(`/${page.toLowerCase()}`);
}
}
};
</script>

What will be the visited pages history when the user navigates between pages and refreshes the page?

  1. A

    The list of visited pages will reset to empty after the page is refreshed.

  2. B

    The list of visited pages will be updated with the current page after every navigation and will not reset even after reload.

  3. C

    The navigation history will not be stored in sessionStorage.

  4. D

    All of these

Show answer

Correct answer

  • B

    The list of visited pages will be updated with the current page after every navigation and will not reset even after reload.

Question 15 of 16 in the IIT Madras BS Modern Application Development II (MAD 2) Quiz 2 paper sat on 16 Mar 2025, in the January 2025 term (IIT M DIPLOMA AN EXAM QDD2 16 Mar 2025). It carries 4.5 marks.

More questions from this paper

  1. Q1Figure question
  2. Q2Figure question
  3. Q3Figure question
  4. Q4Consider the below javascript program. What will be the output of the above program?
  5. Q5Consider the below javascript program. What will be the output of the above program?
  6. Q6Figure question
  7. Q7Consider the below Vue router setup. What will be the behavior when the user visits “/products/123/reviews”?
  8. Q8Consider the below Vuex setup. What will happen if the user dispatches the “addItemToCart” action to add a new item to …
  9. Q9Consider the following javascript code. When the function is called what will be returned if the server is unreachable?
  10. Q10Consider the following javascript code. What's logged?
  11. Q11Consider the following html with relevant vue cdn links added. If a user clicks rapidly twice (within 500ms), what will…
  12. Q12Consider the following html with relevant vue cdn links added. In the Vue application above, what will be the initial r…
  13. Q13Consider the below javascript program. What will be the output of the above program?
  14. Q14Consider the below Vue router setup. Note: Assume that the API “/api/users/userId” is operational and returns the user’…
  15. Q16Consider the below Vue.js application. What will happen if the user submits the form and reloads the page?