js functions Flashcards

1
Q

What is a function in JavaScript?

A

an operation that can take in parameters and returns something, can be called as needed

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

Describe the parts of a function definition.

A
function myFunction(parameter, anotherParameter) {
    code goes here;
    return;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Describe the parts of a function call.

A

myFunction(argument, anotherArgument);

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

When comparing them side-by-side, what are the differences between a function call and a function definition?

A

definition has function keyword, parameters, and body of code; call has arguments

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

What is the difference between a parameter and an argument?

A

function definitions have parameters, calls have arguments. parameters are like placeholders

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

Why are function parameters useful?

A

they allow us to pass data/info into a function, making functions more dynamic and versatile

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

What two effects does a return statement have on the behavior of a function?

A

returns a value from the function, and exits out of the function without running any more of the code

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