icon picker
FullStack JavaScript Quizzes

Booleans and Else If Review

Question 1: Consider the code bellow:
let itemToBuy = '';const savings = 1000;if ( savings > 500 ) { itemToBuy = 'Computer';} else if ( savings > 200 ) { itemToBuy = 'Phone';} else if ( savings > 0 ) { itemToBuy = 'Dinner';} else { itemToBuy = '...still saving...';}
What is the value of the variable itemToBuy after the code runs?
A. ‘Phone’
B. ‘Dinner’
C. ‘...still saving...’
D. Computer
Question 2: Which of the following is a valid conditional statement?
if ( day === 'Friday' ) {console.log("The weekend is almost here.");} else (day === 'Monday' ) {console.log("Here comes another week.");} elseif {console.log("I wonder what day it is?");}
if ( day === 'Friday' ) {console.log('The weekend is almost here.');} else if (day === 'Monday' ) {console.log("Here comes another week.");} else {console.log("I wonder what day it is?");}
if (day === 'Friday' ) {console.log("The weekend is almost here.");} else {console.log("I wonder what day it is?");} else if (day === 'Monday') {console.log( 'Here comes another week.' );}
Question 3: Which of the following operators is called a “strict equality” operator and used to test if two values are exactly the same?
A. !==
B. ==
C. ===
D. >=
Question 4: In a conditional statement with one if clause, two else if clauses and an else clause, what is the maximum number of code blacks in that conditional statement that can run?
A. 4
B. 3
C. 2
D. 1
Question 5: Which JavaScript data type evaluates to either true or false?
A. Number
B. String
C. Conditional
D. Boolean

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
) instead.