Part 2- A Smarter Way to Learn JavaScript Flashcards

1
Q

What’s the tool to get input from a website visitor?

A

Prompt

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

What’s the format for prompt?

A

var question1 = prompt(“What is your street’s name?”, “Suggested response”);

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

How do you suggest an answer for a propmt?

A

var nameOfVariable = prompt(“Question goes here”, “Suggested answer”);

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

Which part of a prompt statement has the user’s response assigned to it?

A

The variable

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

What does the second argument in a prompt statement mean? Like the X in this:
var redFin = prompt (“Hi”, X );

A

It’s the suggested response.

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

What’s the syntax for an IF statement that says, if x = y, then run the code.

A

if (x === y) {
//code that will be run
}

Note the space between IF and the first parentheses. It’s not required, but is the the accepted style.

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

What is the best, strictest symbol for “equals”

A

===

The strict equality ( === ) operator checks whether its two operands are equal, returning a Boolean result.

Unlike the equality operator, the strict equality operator always considers operands of different types to be different.

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

What are these?

!==
>=
<=

A

Comparison Operators (aka Relational Operators)

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

What is the best, strictest symbol for “does not equal”

A

!==

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

What’s the difference between an ELSE statement and an ELSE IF statement?

A

The ELSE statement executes something no matter what. It is not testing anything for truth.

But ELSE IF tests a condition. So it’s like another IF statement that would execute after the previous one failed to.

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

Can an IF statement test for multiple conditions? If so, how?

A

Yes, you can test for multiple conditions.
Join them with && for “and”.
You can also join them with || for “or.”
You can avoid ambiguity by grouping conditions with parentheses, like in math.

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

In an IF statement, what’s the symbol for and?

A

&&

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

In an IF statement, what’s the symbol for or?

A

||

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

If you have multiple conditions to test in an IF statement, how do you avoid ambiguity?

A

Use parentheses to group the terms that should go together

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

If there are several IF statements, does JS go through them all?

A

No. JS stops testing after the first true one it finds.

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

Nested IF statements execute the code between the { } just like any other code, except the code is…

A

…another IF statement

17
Q

How is an array like a variable?

A

an array is just a variable with multiple values (or elements)

18
Q

What’s the index number of the first element in an array?

A

when you’re counting the elements in an array, always start with 0.

19
Q

In an array, what do you call the 0, 1, 2, etc.?

A

The 0, 1, 2, etc. are the array’s INDEX

20
Q

How do you create an array?

A

var arrayName = [6, 7, 8];

arrays are created just like variables by using the VAR keyword. The elements (values) are listed in square brackets and separated by a space and a comma.