curriculum/challenges/english/blocks/quiz-javascript-comparisons-and-conditionals/66edc47c11492ac5cf258ad9.md
To pass the quiz, you must correctly answer at least 9 of the 10 questions below.
What's the result of the expression undefined > 0?
true
undefined
null
false
Which logical operation does || represent?
XOR
AND
NOT
OR
What's the output of the following code?
console.log(5 === 2 + 3 || 4 == 2);
undefined
false
An error is raised.
true
What is a truthy and falsy value?
A value that's both true and false.
A value that changes depending on context.
A value that functions differently than true or false value.
A value that is considered true or false when encountered in a Boolean context.
What's logged to the console from the code below?
if (1) {
console.log("True!");
}
false
Nothing gets printed to the console.
An error is raised.
True!
What's the difference between undefined and null?
null and undefined point to an out-of-range memory location and are inaccessible.
null is the implicit value assigned to variables and it can not be changed, while undefined is the explicit value assigned to variables.
null is a global property, undefined is not.
Variables without a value are undefined, while null represents an intentional absence of an object value.
What happens when you don't include break while implementing a switch statement?
The switch statement will stop abruptly.
The switch statement will throw an error after previous statement.
The switch statement will exit after the first match.
The code continues to evaluate the following case statements, even after finding a match.
What is printed to the console from the code below?
const a = 2;
if (1 == "1") {
let b = 3;
console.log(a + b);
}
console.log(b);
An error is raised.
5
3
5
undefined
5, and then an error is raised.
What will be the output of the following JavaScript code?
let vehicle = "car";
switch (vehicle) {
case "bike":
console.log("Bikes are two-wheelers.");
break;
case "car":
console.log("Some cars are 4x4.");
case "truck":
console.log("Trucks can carry heavy loads.");
break;
default:
console.log("Unknown vehicle.");
}
Some cars are 4x4.
Some cars are 4x4.
Trucks can carry heavy loads.
Unknown vehicle.
Unknown vehicle.
Some cars are 4x4.
Trucks can carry heavy loads.
What is printed to the console with code below?
let x = 5;
if (x > 1 && x < 10) {
console.log("x is between 1 and 10");
} else {
console.log("x is not between 1 and 10");
}
An error is raised.
Nothing is printed.
x is not between 1 and 10
x is between 1 and 10