1
2
3
4
5
6
7
8
9
10
To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to CodePen.
0,1,2,3,4,5,6,7,8,9
0
0
0
0
A variable that starts out with an initial value, and then is switched to a different value under certain conditions is a _____. | flag | flag | |
The values true and false are _________ values. | Boolean | [Bb]oolean | |
Set the initial value of a flag, isNegativeNumber, to the positive Boolean. | let isNegativeNumber = true; | letisNegativeNumber=true; | |
Reverse the value of isNegativeNumber, whose initial value was true. | isNegativeNumber = false; | isNegativeNumber=false; | |
Set the initial value of a flag that hasn't been previously declared. Make up the flag name and its Boolean value. | let checkedOut = true; or let checkedOut = false; | let[a-z_$][a-zA-Z0-9_$]*=(true|false); | |
When the following code runs, how many times will the "Sorry" alert display before the "Congratulations" alert displays? Answer with a number, like 1. | let popDogs = ["Poodle", "Sheltie", "Lab", "Husky", "Pug"]; let breedToCheck = "Husky"; for (let i = 0; i < 5; i++) { if (breedToCheck === popDogs[i]) { alert("Congratulations!"); break; } else { alert("Sorry"); } } |
3 | 3 |
Code an alert that executes after the loop is finished. The alert says "Sorry" if no match has been found. | let matchFound = false; for (let i = 0; i < 5; i++) { if (breedToCheck === popDogs[i]) { alert("Congratulations!"); matchFound = true; break; } } |
if (matchFound === false) { alert("Sorry"); } |
if\(matchFound===false\){[\r\n]alert\(•Sorry•\);[\r\n]} |
In the following loop, code the missing statement. | let matchFound = false; for (let i = 0; i < 5; i++) { if (breedToCheck === popDogs[i]) { alert("Congratulations!"); ___________________ break; } |
matchFound = true; | matchFound=true; |
|
|||
|