Quiz Space

Modern Application Development II · Quiz 1 · 13 Jul 2025 · May 2025 term

Question 5: What will be the output of this code?

Question 5

+3 marksOne correct option

What will be the output of this code?

javascript
function createFunctions() {
var funcs = [];
for (var i = 0; i < 3; i++) {
funcs.push(function() {
return i;
});
}
return funcs;
}
const functions = createFunctions();
console.log(functions[0](), functions[1](), functions[2]());
  1. A

    0, 1, 2

  2. B

    1, 2, 3

  3. C

    undefined, undefined, undefined

  4. D

    3, 3, 3

Show answer

Correct answer

  • D

    3, 3, 3

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

More questions from this paper

  1. Q1In Vue 2, what happens when you update a data property?
  2. Q2Consider the following HTML, with the correct Vue 2 CDN links included: Html code. script: If the user clicks the "Add …
  3. Q3Consider the following code. What will be the output?
  4. Q4Figure question
  5. Q6Which computed property implementation is INCORRECT?
  6. Q7Consider the following JavaScript code: What will be the output of the code?
  7. Q8Consider the following JavaScript code to answer the below question: What will be the result of all the console.log aft…
  8. Q9Consider the following Vue.js (Vue 2) code to answer the following question: What will be displayed when the page loads…
  9. Q10Consider the following JavaScript program: What will be the output of the above program?
  10. Q11Consider the following JavaScript code snippet: What will be the output of the above JavaScript code?
  11. Q12Consider the following JavaScript code to answer the below question: Which of the following statements is/are TRUE?
  12. Q13You're building a basic Vue app using Vue 2 via CDN to show a user's login form. You want to: Show a welcome message on…
  13. Q14You're building a basic Vue app using Vue 2 via CDN to show a user's login form. You want to: Show a welcome message on…
  14. Q15Consider the following HTML with relevant Vue 2 CDN link attached and answer the given subquestions. Html file: script
  15. Q16Consider the following HTML with relevant Vue 2 CDN link attached and answer the given subquestions. Html file: script