Grokking JavaScript Fundamentals
Ask Author
Back to course home

0% completed

Vote For New Content
Quiz
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

What is the output of the following code snippet using a for loop?
for(let i = 0; i < 3; i++) {
    console.log(i);
}
A
0 1 2
B
1 2 3
C
0 1 2 3
D
undefined
How many times does the following while loop run?
let i = 5;
while(i > 0) {
    i--;
}
console.log(i);
A
4
B
5
C
6
D
0
What does the following do-while loop output?
let i = 3;
do {
    console.log(i);
    i++;
} while(i < 3);
A
Prints 3 only
B
Prints 3 and then 4
C
No output
D
undefined
What will be the output of the following for-in loop?
const obj = {a: 1, b: 2, c: 3};
for (let prop in obj) {
    console.log(prop);
}
A
1 2 3
B
"a" "b" "c"
C
undefined
D
"a: 1", "b: 2", "c: 3"
Given an array arr = [10, 20, 30, 40, 50];, which loop correctly logs each element?
Choose all correct options
for(let i = 0; i <= arr.length; i++) { console.log(arr[i]); }
for(let i = 0; i < arr.length; i++) { console.log(arr[i]); }
arr.forEach(i => console.log(i));
Both B and C are correct.
What is the final value of x after this do-while loop executes?
let x = 0;
do {
    x++;
} while(x < 5);
console.log(x);
A
4
B
5
C
6
D
undefined
Which method is used to iterate over array arr = ['a', 'b', 'c'] and execute a function for each element?
Choose all correct options
arr.loop(function(element) { ... });
arr.forEach(function(element) { ... });
for(let element of arr) { ... }
Both B and C are correct.

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible