This type of variable can only be true or false.
What is boolean?
let number = 5;
if (number > 0){
console.log(number);
}
This is the output of the code above...
What is 5?
This is what you should use to repeat something until a certain condition is met...
What is a while loop?
for (let i=0; i < 7; i++) {
console.log("yo");
}
This is the number of times that "yo" will print...
What is 7?
These are the 3 main logical operators. One reverses a boolean's value, one returns whether two booleans are both true, and one returns whether at least one of two booleans is true.
What are the NOT (!), AND (&&), and OR (||) operators?
let numApples = 10;
let numOranges = 5;
if(numApples < 20 || numOranges == numApples){
console.log("Open");
} else {
console.log("Closed");
}
What is "Open"?
This keyword is what you can use to stop a loop early...
What is break?
for (let i = 100; i > 0; i -= 20) {
console.log("hi");
}
This is the number of times "hi" will print...
What is 5?
let target = (x<22 && x>20);
For target to be true, x would have to be this integer...
What is 21?
let above16 = true;
let hasPermit = true;
let passedTest = false;
if (above16 && hasPermit && passedTest){
console.log("Issue Driver's License");
} else {
if (above16 || hasPermit || passedTest) {
console.log("Almost eligible for Driver's License");
} else {
console.log("No requirements met.");
}
}
What is "Almost eligible for Driver's license" ?
let i = 0;
while(i < 10){
console.log("hello");
}
This is how many times the code above will print "hello"...
What is infinity?
for(let i = 30; i >= 10; i-=5){
if(i % 2 == 0){
console.log(i * 2);
} else {
console.log(i);
}
}
This is the last thing printed by the code above...
What is 20?
let age = 17;
let isCitizen = true;
let canVote = age >= 18 || isCitizen;
This is the value of canVote...
What is true?
if ( x ) {
console.log( "cat" );
} else {
console.log( "dog" );
}
To print "dog", x needs to be this value...
What is false?
while (x > 1) {
console.log("Divide");
x = x / 2;
}
This is the number of times the code above will print "Divide"...
What is 4 times?
for (let j = 0; j < 2; j++) {
for (let i = 3; i > 1; i--){
console.log(i);
}
}
This is what the code above will print...
What is 3, 2, 3, 2?
5 >= 6
false || !true
!( "blue" != "red" && true)
This many of the statements above are true...
What is zero?
let numberOne = 5;
let numberTwo = 10;
if (numberOne == 5) {
console.log(1);
}
if (numberOne < numberTwo) {
console.log(2);
}
if (numberOne != numberTwo) {
console.log(3);
}
What is 1, 2, and 3?
let word = "ha";
while (true) {
if (word == "hahaha") {
break;
} else {
word = word + "ha";
console.log("laugh");
}
}
This is the number of times "laugh" will print...
What is 2 times?
let result = 0;
let max = 5;
for(let i = 0; i < max; i++){
result += i;
}
This is the value of result after this code finishes...
What is 10?