javascript-methods Flashcards

1
Q

Why do we log things to the console?

A

to check if our functions are returning the values that we are expecting them to.

its a devs way of talking to the console. it spits out values that we can see

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

What is a method?

A

a method is a function that is stored in the property of an object

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

How is a method different from any other function?

A

a method does not need to be defined and it is usually attached to an object.

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

How do you remove the last element from an array?

A

.pop method

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

How do you round a number down to the nearest integer?

A

math.floor method goes DOWN ALWAYS

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

How do you generate a random number?

A

Math.random returns a random number between 0 and 1

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

How do you delete an element from an array?

A

.splice method.. similar to pop but this allows you to choose your spot

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

How do you append an element to an array?

A

.push adds a string to the end of an array

.unshift adds a string to the beginning of an array

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

How do you break a string up into an array?

A

.split allows you to break a string up into an array

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

Do string methods change the original string? How would you check if you weren’t sure?

A

some can but not all do. in order to see if the string method had any effect on the original string, you would console log it to see the current value

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

Roughly how many string methods are there according to the MDN Web docs?

A

50

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

Is the return value of a function or method useful in every situation?

A

it depends on the situation.

ex. pop method return doesnt matter sometimes bc u are looking to get rid of the value and trash it

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

Roughly how many array methods are there according to the MDN Web docs?

A

a lot -quan

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

What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?

A

MDN

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