What is the value of the boolean variable canVote at the end of this program?
var age = 17;
var isCitizen = true;
var canVote = age >= 18 && isCitizen;
Javascript Control Structures Practice

Flashcard
•
Computers
•
9th - 12th Grade
•
Hard
Quizizz Content
FREE Resource
Student preview

14 questions
Show all answers
1.
FLASHCARD QUESTION
Front
Back
False
Answer explanation
The variable canVote is determined by the expression age >= 18 && isCitizen. Since age is 17 (not >= 18), the expression evaluates to false. Therefore, the value of canVote is False.
2.
FLASHCARD QUESTION
Front
What will be the output of this program?
var number = 5;
var greater_than_zero = number > 0;
if (greater_than_zero){
println(number);
}
Back
5
Answer explanation
The variable 'number' is set to 5. The condition 'greater_than_zero' evaluates to true since 5 > 0. Therefore, the program prints the value of 'number', which is 5.
3.
FLASHCARD QUESTION
Front
What will be the output of this program?
var number = 5;
var greater_than_zero = number > 0;
if (greater_than_zero){
if (number > 5){
println(number);
}
}
Back
Nothing will print
Answer explanation
The variable 'greater_than_zero' is true since 5 > 0. However, the inner condition 'number > 5' is false, so 'println(number)' does not execute. Therefore, nothing will print.
4.
FLASHCARD QUESTION
Front
What is printed by the following program?
var isRaining = false;
var isCloudy = false;
var isSunny = !isRaining && !isCloudy;
var isSummer = false;
var isWarm = isSunny || isSummer;
println("Is it warm: " + isWarm);
Back
Is it warm: true
Answer explanation
isSunny is true because both isRaining and isCloudy are false. isWarm is true since isSunny is true, regardless of isSummer. Therefore, the output is 'Is it warm: true'.
5.
FLASHCARD QUESTION
Front
What is printed by the following program?
var numApples = 10;
var numOranges = 5;
if(numApples < 20 || numOranges == numApples){
println("Hello, we are open!");
} else {
println("Sorry, we are closed!");
}
println("Sincerely, the grocery store");
Back
Hello, we are open!
Sincerely, the grocery store
Answer explanation
The condition 'numApples < 20' is true (10 < 20), so 'Hello, we are open!' is printed. The final line 'Sincerely, the grocery store' is also printed, making the correct choice: 'Hello, we are open!' and 'Sincerely, the grocery store'.
6.
FLASHCARD QUESTION
Front
What will the following program print when run?
var above16 = true;
var hasPermit = true;
var passedTest = false;
if (above16 && hasPermit && passedTest){
println("Issue Driver's License");
} else {
if (above16 || hasPermit || passedTest) {
println("Almost eligible for Driver's License");
} else {
println("No requirements met.");
}
}
Back
Almost eligible for Driver’s License
Answer explanation
The program checks if all conditions (above16, hasPermit, passedTest) are true. Since passedTest is false, it goes to the else block. One condition is true (above16), so it prints 'Almost eligible for Driver's License'.
7.
FLASHCARD QUESTION
Front
What will the following program print when run?
var numberOne = 5;
var numberTwo = 10;
if (numberOne == 5) {
println(1);
}
if (numberOne > 5) {
println(2);
}
if (numberTwo < 5) {
println(3);
}
if (numberOne < numberTwo) {
println(4);
}
if (numberOne != numberTwo) {
println(5);
}
Back
1
4
5
Answer explanation
The program prints 1 because numberOne is 5. It does not print 2 or 3 since those conditions are false. It prints 4 because numberOne (5) is less than numberTwo (10) and prints 5 because numberOne is not equal to numberTwo.
Create a free account and access millions of resources
Similar Resources on Quizizz
12 questions
CS Python Fundamentals Unit 4 Review

Flashcard
•
9th - 12th Grade
15 questions
CodeHS Python Unit 7 Looping Flashcard Review

Flashcard
•
9th - 12th Grade
10 questions
Methods and conditional warm up 1

Flashcard
•
10th Grade
12 questions
AP CSP Loops Practice

Flashcard
•
9th - 12th Grade
10 questions
Arrays

Flashcard
•
10th - 12th Grade
13 questions
AP CSP Unit 7: Parameters, Returns, and Libraries

Flashcard
•
9th - 12th Grade
12 questions
Code.org - Unit 6 Lists, Loops, and Traversals

Flashcard
•
10th Grade - University
12 questions
CSP-A114 Flashcard

Flashcard
•
9th - 12th Grade
Popular Resources on Quizizz
15 questions
Multiplication Facts

Quiz
•
4th Grade
20 questions
Math Review - Grade 6

Quiz
•
6th Grade
20 questions
math review

Quiz
•
4th Grade
5 questions
capitalization in sentences

Quiz
•
5th - 8th Grade
10 questions
Juneteenth History and Significance

Interactive video
•
5th - 8th Grade
15 questions
Adding and Subtracting Fractions

Quiz
•
5th Grade
10 questions
R2H Day One Internship Expectation Review Guidelines

Quiz
•
Professional Development
12 questions
Dividing Fractions

Quiz
•
6th Grade
Discover more resources for Computers
25 questions
Spanish preterite verbs (irregular/changed)

Quiz
•
9th - 10th Grade
10 questions
Identify Slope and y-intercept (from equation)

Quiz
•
8th - 9th Grade
10 questions
Juneteenth: History and Significance

Interactive video
•
7th - 12th Grade
8 questions
"Keeping the City of Venice Afloat" - STAAR Bootcamp, Day 1

Quiz
•
9th - 12th Grade
26 questions
June 19th

Quiz
•
4th - 9th Grade
20 questions
Distance, Midpoint, and Slope

Quiz
•
10th Grade
20 questions
Figurative Language Review

Quiz
•
10th Grade
27 questions
STAAR English 1 Review

Quiz
•
9th Grade