Part 3- A Smarter Way to Learn JavaScript Flashcards

1
Q

What are the rules for naming an array?

A

array names have the same naming conventions as other variables

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

What types of data can an array hold?

A

Same as any other variable: strings, numbers, variables

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

Can you mix data types in the same array?

A

Yes.

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

Which punctuation is used in an array?

A

*the list of elements has square brackets: [],

*you separate elements in the list with a comma and a space

*in an array of strings, the comma between elements goes AFTER the quotation mark.

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

In an array, what’s another name for a value?

A

an element

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

How do you formally refer to a specific element in an array?

A

The array’s name
followed by the index number inside of straight brackets

For example, cities[5] would be how you refer to the sixth element in an array called CITIES

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

What’s the keyword to add elements to the end of an array?

A

*push()

*arrayname.push(elements);

*Think of it as “push parentheses”

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

What’s the keyword to remove the last element of an array?

A

pop();
arrayname.pop();
Think of it as “pop parentheses”

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

Do you have to add all elements to an array in order?

A

No.

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

What happens if you call an element and it hasn’t been assigned?

A

It will return “undefined.”

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

What are the six keywords used to change the elements in an array?

A

pop()
push()
shift()
unshift()
splice()
slice()

*Each of these methods RETURNS a value. When we get to the W3Schools tutorial, I’ll learn which value each returns

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

What do pop() and shift() have in common?

A

They both remove elements from an array

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

What do push() and unshift() have in common?

A

They both add elements to an array

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

What do pop() and push() have in common?

A

They both work at the end of an array

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

What do shift() and unshift() have in common?

A

They both work at the beginning of an array

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

What do splice() and slice() have in common?

A

They both work in the middle of an array

17
Q

How is slice() different from pop(), push(), shift(), unshift(), and splice()?

A

It does not affect the existing array/string (usually)
It creates a new array/string (usually)

(Technically, you could splice from the existing array BACK TO the existing array, but it would remove all the non-sliced elements from the existing array)

18
Q

The methods slice() and splice() both use two numbers in the parentheses. What do they mean?

A

*For both slice() and splice(), the first number in parentheses is the index number where the work starts.

*for slice(), the second number is the index number AFTER the final element to be removed.

*for splice(), the second number is the total number of elements being removed.

19
Q

What’s a colloquial way to think of the ELSE IF command?

A

“If that’s not true, check this:”

or

“If that doesn’t match, try this:”

20
Q

What is this code?

for (var 1 = 0; i<=4; i++) {
//code to run goes here
}

A

a FOR loop