if statements Flashcards

1
Q

What are the first 4 characters of an if statement?

A

if (

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What character ends the first line of an if statement?

A

{

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the last line of an if statement?

A

}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

if (city = “Las Vegas”) {

In the above statement, what character is incorrect?

A

It should be ===

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

if (firstName === “John”) {

Complete the if statement. If the condition is true, display an alert that says, “Hi, John”.

A

alert(“Hi, John”);

}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Code the first line of an if statement that tests whether one variable has the same value as another.

A

if (firstName === nickname) {

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Code the first line of an if statement that tests whether a variable has the value of a particular string.

A

if (gender === “female”) {

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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.

A
var answer = prompt("What is z?");
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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

A

if (pCode === “10010”) {
city = “New York”;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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;

A

if (pets === 1) {
pets = 2;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly