True or false: In JavaScript, an empty array is truthy when it is evaluated as the condition of an if statement.
3 Conditionals and Boolean Logic Online Quiz Questions
Use this free practice quiz with 20 questions to review 3 Conditionals and Boolean Logic, test your knowledge, and prepare for your next test or exam.
Which JavaScript expression evaluates to true because it allows type conversion between a number and a string?
- A
5 === "5" - B
5 == "5" - C
5 !== "5" - D
5 === 5
Complete the statement: To require that a customer is a member has spent at least $50, combine the two conditions with the JavaScript operator shown in the blank.
What JavaScript term describes a non-Boolean value that behaves like true when used as an if condition?
Given const user = null;, what happens in if (user && user.name) { ... }?
- A
It throws an error while evaluating
user.name. - B
It skips evaluating
user.name. - C
It changes
userinto an empty object. - D
It evaluates
user.nameand returnsundefined.
True or false: If a program checks age >= 18 before age >= 65 in an else if chain, the senior branch can still run for an age of 70.
- A
True
- B
False
Complete the statement: The JavaScript operator that reverses a Boolean condition is .
Which values are falsy in JavaScript? Select all correct choices.
- A
0 - B
"" - C
null - D
undefined - E
NaN - F
[]
What string is assigned to displayName by this code? const enteredName = ""; const displayName = enteredName || "Guest";
Which JavaScript condition correctly implements this rule: a discount applies when a customer is a member who spends at least $50, or when the customer has a promotional code?
- A
(isMember && purchaseTotal >= 50) || hasPromoCode - B
isMember || purchaseTotal >= 50 || hasPromoCode - C
isMember && (purchaseTotal >= 50 || hasPromoCode) - D
(isMember || purchaseTotal >= 50) && hasPromoCode
Which practices help make JavaScript conditional logic clearer or less error-prone? Select all correct choices.
- A
Prefer
===and!==for comparisons by default. - B
Use braces around conditional branches.
- C
Test values just below, exactly at, and just above a limit.
- D
Use
score = 10when you need to test whetherscoreequals 10.
Explain a reliable process for designing and checking a JavaScript conditional that has multiple requirements and boundary values. Include one correctly grouped Boolean expression as an example.
What does this code print when age is 70?
if (age >= 65) { console.log("Senior"); } else if (age >= 18) { console.log("Adult"); } else { console.log("Minor"); }
- A
It prints
Minor. - B
It prints
Adult. - C
It prints
Senior. - D
It prints nothing because both conditions are true.
Which value is truthy in JavaScript?
- A
0
- B
""
- C
[]
- D
null
True or false: In JavaScript, user && user.name safely avoids attempting to read name when user is null.
- A
True
- B
False
What is the result of the JavaScript expression 18 === "18"?
- A
true
- B
false
- C
It throws an error
- D
It returns the string "false"
Which JavaScript logical operator requires both conditions to be true?
Given isMember = true, purchaseTotal = 35, and hasPromoCode = false, what is the value of (isMember && purchaseTotal >= 50) || hasPromoCode?
- A
true
- B
false
- C
It evaluates to the purchase total, 35
- D
It evaluates to the string "No"
Which if...else if...else chain correctly labels a person who is 65 or older as Senior, a person aged 18 through 64 as Adult, and anyone younger than 18 as Minor?
- A
if (age >= 65) { console.log("Senior"); } else if (age >= 18) { console.log("Adult"); } else { console.log("Minor"); } - B
if (age >= 18) { console.log("Adult"); } else if (age >= 65) { console.log("Senior"); } else { console.log("Minor"); } - C
if (age < 18) { console.log("Minor"); } else if (age < 65) { console.log("Senior"); } else { console.log("Adult"); } - D
if (age >= 65) { console.log("Adult"); } else if (age >= 18) { console.log("Senior"); } else { console.log("Minor"); }
Which JavaScript operator assigns a fallback only when the left operand is null or undefined?
Related study packs and tools
2 Digital Logic
A 14-question medium-difficulty quiz on Boolean algebra, logic gates, truth tables, and combinational circuits.
03 — Python Programming Fundamentals
A focused set of flashcards covering Python variables, data types, expressions, control flow, functions, input, output, and common programming practices.
04 Conditionals and Boolean Logic
Learn how Boolean expressions, logical operators, and conditional structures let programs make reliable decisions, including how to handle boundaries, branch order, and testing.
6 Computer Memory
Learn how computer memory stores and addresses information, how RAM and ROM differ, and how caches and the memory hierarchy balance speed, capacity, and cost.
07 Trees and Binary Search Trees
A progressive guide to tree structure, binary-tree traversals, binary search tree operations, deletion, balancing, and the way tree height determines time and space costs.
12 — Foundations Capstone: Integrating Computer Science
A practical guide to integrating problem definition, data representation, modular programming, algorithms, complexity analysis, testing, correctness, and ethical evaluation into a responsible computer science capstone.
Interrupts
Reviews how interrupts support event handling and multitasking, and how Linux system calls use the RISC-V `ecall` instruction and register conventions.
OS Processes
This quiz covers process management, context switching and scheduling, multitasking, traps and interrupts, and RISC-V privilege transitions.
Systemcalls
A quiz on operating-system system calls, including privileged-operation requests, process creation and execution with fork, exec, and waitpid, and signal handling.