Quiz Space

Modern Application Development II · Quiz 2 · 6 Aug 2023 · May 2023 term

Question 4: Consider the following Vue application with javascript fi…

Question 4

+3 marksOne correct option

Consider the following Vue application with javascript file “app.js” and markup file “index.html”.

index.html:

html
<body>
<div id="app"></div>
</body>

app.js:

javascript
const Category = {
template:
`<div>{{$route.params.name}}<router-view></router-view></div>`,
}
const Error = {
template: `<div><slot> Page Not Found </slot></div>`,
}
const Product = {
template: `
<div>
<div v-if='filteredProducts.length > 0'>
<div v-for='product in filteredProducts'>
Name: {{product.name}}, Price: {{product.price}}
</div>
</div>
<Error v-else> No {{keyword}} Found </Error>
</div>`,
data() {
return {
keyword: this.$route.params.name,
products: [
{ category: 'Mobile', name: 'Samsung', price: '10K' },
{ category: 'Mobile', name: 'Apple', price: '50K' },
{ category: 'Laptop', name: 'Lenovo', price: '70K' },
],
}
},
javascript
computed: {
filteredProducts() {
return this.products.filter(
(product) =>
product.category.toLowerCase() ==
this.keyword.toLowerCase()
)
},
},
components: {
Error,
},
}
const router = new VueRouter({
routes: [
{
path: '/category/:name',
component: Category,
children: [{ path: 'product', component: Product }],
},
{ path: '*', component: Error },
],
})
new Vue({
el: '#app',
template: '<div><router-view /></div>',
router,
})

Suppose the application is running on “http://localhost:8080”. What will be rendered by the browser for the URL “http://localhost:8080/#/category/desktop/product”?

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

Correct answer

  • C

Question 4 of 16 in the IIT Madras BS Modern Application Development II (MAD 2) Quiz 2 paper sat on 6 Aug 2023, in the May 2023 term (IIT M FOUNDATION AN2 EXAM QPF2 06 Aug 2023). It carries 3 marks.

More questions from this paper

  1. Q1Consider the below javascript program. What will be the approximate value of the variable “timeDifference”?
  2. Q2Consider the following Vue application with javascript file “app.js” and markup file “index.html”. app.js: index.html: …
  3. Q3Consider the following Vue application with javascript file “app.js” and markup file “index.html”. index.html: app.js: …
  4. Q5Consider the following Vue application with javascript file “app.js” and markup file “index.html”. index.html app.js Su…
  5. Q6Consider the below javascript program, and predict the output, if executed.
  6. Q7Which of the following is correct regarding the finally block of Promise?
  7. Q8Which of the following statements is true?
  8. Q9Consider the following Vue application with javascript file “app.js” and markup file “index.html”. index.html: Suppose …
  9. Q10Consider the following Vue application with javascript file “app.js” and markup file “index.html”. index.html: app.js: …
  10. Q11Consider the below javascript program, and predict the output, if executed.
  11. Q12Consider the below javascript program. Assuming the variable “x” passed to the “result” function is a whole number betw…
  12. Q13Which of the following statement(s) is/are true regarding javascript?
  13. Q14Figure question
  14. Q15Consider the below Vue class bindings: Code 1: Code 2: Which of the following statement(s) is/are true?
  15. Q16Which of the following statement(s) is/are correct in the context of REST and GraphQL?