Functions Flashcards

1
Q

What are “ Functions “?

A

A function is a block of code designed to perform a particular task.

A function is executed when “something” invokes it (calls it).

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

How do you declare a Function?

A

The function keyword goes first, then the function name, then a list of parameters between the parentheses, and then the code of the function between curly braces.

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

How do you call a function?

A

A function can be called using it’s name.

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

What are “ Local “ variables?

A

A variable declared inside a function is Local and only visible inside that function.

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

What are “ Global/Outer “ variables?

A

Variables declared outside of a function are called global and are visible from any function.

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

What is a “ Parameter “?

A

A parameter is the variable listed inside the parentheses in the function declaration. In this example, (from, text).

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

What is a “ Argument “?

A

An argument is the value that is passed to the function parameter when it is called. In this example, (“Ann”, “Hello”).

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

What is a default value?

A

A default value can be specified in the function declaration. This value will be used if argument is not specified in the function call.

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

What is the preferred way to name a function?

A

Functions are actions. So their name is usually a verb. It should be brief, as accurate as possible and describe what the function does.

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