What are the first 4 characters of an if statement?
Sorry, that's incorrect. The correct answer:
if (
What character ends the first line of an if statement?
Sorry, the correct answer is:
{
What is the last line of an if statement?
Sorry, that's incorrect. The correct answer:
}
if (city = "Las Vegas") {
In the above statement, what character is incorrect?
Sorry, that's incorrect. The correct answer:
=
It should be ===
Drag-and-drop. Holding down the left mouse button, drag the pieces to create this if statement: If a has the value of b, x has the value of y.
Click in the box and type the next character. I'll autocomplete. Don't type spaces.
Code the first line of an if statement that tests whether teammates has the value of 8.
The correct code is:
if (teammates === 8) {
Fail-safe coding. If you type the wrong character, I'll cancel the keystroke. Type spaces and carriage returns.
This is the first line of an if statement.
if (firstName === "John") {
Complete the if statement. If the condition is true, display an alert that says, "Hi, John".
The correct code:
alert("Hi, John");
}
Code the first line of an if statement that tests whether one variable has the same value as another.
Sorry, that's incorrect. An example:
if (firstName === nickname) {
Code the first line of an if statement that tests whether a variable has the value of a particular string.
Sorry, that's incorrect. An example:
if (gender === "female") {
This is the first line of an if statement:
if (x === y) {
Complete the statement. If the condition is true, display a box that asks the user a question. Assign the answer to a variable that hasn't been declared beforehand.
Sorry, that's incorrect. An example:
var answer = prompt("What is z?");
}
Code an if statement that tests whether pCode is "10010". If so, assign to the variable city the string "New York". city has already been declared.
Sorry, that's incorrect. The correct answer:
if (pCode === "10010") {
city = "New York";
}
Code an if statement. Test whether a variable has a particular numerical value. If so, assign a new value to that variable, as in x = 1;
Sorry, that's incorrect. An example:
if (pets === 1) {
pets = 2;
}
Time goal: 15 seconds. (The timer starts when you click in the answer field.)
What are the 4 bracket characters in every if statement, in order?.
Sorry, that's incorrect. The correct answer:
(){}
Time goal: 35 seconds. Code the first line of an if statement that tests whether one variable has the same value as another.
Sorry, that's incorrect. An example:
if (firstName === nickname) {
Time goal: 35 seconds. Code the first line of an if statement that tests whether a variable has the value of a particular string.
Sorry, that's incorrect. An example:
if (gender === "female") {
Time goal: 35 seconds. This is the first line of an if statement:
if (x === y) {
Complete the statement. If the condition is true, display a box that asks the user a question. Assign the answer to a variable that hasn't been declared beforehand.
Sorry, that's incorrect. An example:
var answer = prompt("What is z?");
}
Time goal: 60 seconds. Code an if statement that tests whether pCode is "10010". If so, assign to the variable city the string "New York". city has already been declared.
Sorry, that's incorrect. The correct answer:
if (pCode === "10010") {
city = "New York";
}
Time goal: 45 seconds. Code an if statement. Test whether a variable has a particular numerical value. If so, assign a new value to that variable, as in x = 1;
Sorry, that's incorrect. An example:
if (pets === 1) {
pets = 2;
}
Live coding exercise:
Live coding exercise:
To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to jsFiddle. See my brief demo of jsFiddle.
Post a review on Amazon for the paperback or the Kindle edition.
Email me to give me a compliment, complaint, or correction. I'll respond.
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19