Well done!
You have completed Iterating with Loops in JavaScript: Types and Applications Quiz!
Quiz Question 1 of 5
Consider the following code:
const book = {title: "1984", author: "George Orwell", year: 1949};
let output = "";
for (let prop in book) {
if (prop === "year") {
continue;
}
output += book[prop] + " ";
}
console.log(output);
What will be the output of the code, and which principle of loop control is demonstrated here?
Choose the correct answer below:
-
A
1984 George Orwell 1949
— Demonstrates the use ofbreak
to exit the loop early. -
B
1984
— Demonstrates the selective filtering of object properties. -
C
1984 George Orwell
— Demonstrates the use ofcontinue
to skip a loop iteration. -
D
George Orwell 1949
— Demonstrates the incorrect use of thefor..in
loop.