javascript-functions Flashcards

1
Q

What is a function in JavaScript?

A

a function in javaScript is a tool that lets you package lines of code that perform a certain task, then get’s names so it can be reused more than once.

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 keyword followed by the function’s optional name followed by parentheses that house a/multiple parameters (variables). followed by curly braces that signify the start of the code block. and within the braces there is code

function add() {}

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

name of the function directly followed by an argument/s (if it accepts any), followed by a semi colon

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

a function call does not include the function keyword.

a function call is passed with an argument, not a parameter.

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

A parameter is not real data.
A parameter is only included in the function definition.

An argument is only included when calling the function
An argument is real input.

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

Why are function parameters useful?

A

A parameter acts as a placeholder for an argument. they serve as a reminder for the type of data that should be passed as arguments when the function is called. A single tool that allows your function to be used in many situations

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

a return statement exits the function and causes a function to produce a value that can be used outside of the function

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