You can prepare effectively for Software Development JavaScript for Web Development with this dedicated MCQ Practice Test (available with solutions) on the important topic of "Test: Loops in JS - 2". These 15 questions have been designed by the experts with the latest curriculum of Software Development 2026, to help you master the concept.
Test Highlights:
Sign up on EduRev for free to attempt this test and track your preparation progress.
Which loop in JavaScript is suitable when the number of iterations is unknown?
Detailed Solution: Question 1
Which loop in JavaScript is used to iterate over the properties of an object?
Detailed Solution: Question 2
What is the key difference between a for loop and a for...in loop?
Detailed Solution: Question 3
Which loop in JavaScript is used to iterate over the elements of an array?
Detailed Solution: Question 4
Detailed Solution: Question 5
What will be the output of the following code?
let i = 1;
while (i <= 5) {
console.log(i);
i++;
}
Detailed Solution: Question 6
What will be the output of the following code?
let obj = { a: 1, b: 2, c: 3 };
for (let key in obj) {
console.log(key);
}
Detailed Solution: Question 7
What will be the output of the following code?
let arr = [1, 2, 3, 4, 5];
for (let element of arr) {
console.log(element);
}
Detailed Solution: Question 8
What will be the output of the following code?
let i = 5;
do {
console.log(i);
i--;
} while (i >= 1);
Detailed Solution: Question 9
What will be the output of the following code?
let obj = { a: 1, b: 2, c: 3 };
for (let value of obj) {
console.log(value);
}
Detailed Solution: Question 10
Which loop is more suitable for iterating over the values of an iterable object like an array?
Detailed Solution: Question 11
Which loop is used to iterate over the characters of a string?
Detailed Solution: Question 12
What is the output of the following code?
let obj = { a: 1, b: 2, c: 3 };
for (let key in obj) {
console.log(obj[key]);
}
Detailed Solution: Question 13
What will be the value of 'i' after the execution of the following code?
let i = 0;
for (; i < 5; i++) {}
Detailed Solution: Question 14
What will be the output of the following code?
let arr = [1, 2, 3, 4, 5];
for (let element of arr) {
if (element === 3) {
break;
}
console.log(element);
}
Detailed Solution: Question 15
51 videos|32 docs|12 tests |