Quiz Space

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

Question 5: Consider the following code snippet. What will be logged …

Question 5

+3 marksOne correct option

Consider the following code snippet.

javascript
const response = {
meta: () =>
Promise.resolve([
{ id: 1, score: 20 },
{ id: 2, score: 40 },
]),
json: () =>
Promise.resolve([
{ name: "Alpha", score: 40 },
{ name: "Beta", score: 30 },
{ name: "Charlie", score: 50 },
{ name: "Delta" }, // no score
]),
};
fetchData();
function fetchData() {
Promise.resolve(response)
.then((res) => res.json())
.then((data) => {
const total = data
.map((p) => parseInt(p.score) || 0)
.filter((score) => score >= 40)
.reduce((acc, score) => acc + score, 0);
console.log("Total Score:", total);
});
}

What will be logged to the console?

  1. A

    Total Score: 80

  2. B

    Total Score: 90

  3. C

    Total Score: 120

  4. D

    Total Score: NaN

Show answer

Correct answer

  • B

    Total Score: 90

Question 5 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. Q6The following code is using Vue 2 and Vue router 3 running on http://127.0.0.1:5500. Filename: index.html Filename: rou…
  6. Q7Consider the following Vue 2 component defined using the CDN version: Filename: index.html Filename: app.js What will b…
  7. Q8Consider the following JavaScript program: What will be the output of the above program when executed?
  8. Q9Consider the following Vue application with markup "index.html" and JavaScript file "app.js". Filename: index.html File…
  9. Q10Consider the following Vue 2 code with Vuex 3 used via CDN, assume the Vuex store is correctly injected into the Vue in…
  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…