Understanding functions Flashcards

1
Q

Why are functions like black boxes?

A

Because we can use them without knowing the code inside of them

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

How do we decide a function’s input?

A

Based on the output we want

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

What happens when we pass the wrong type of value to a function?

A

The function won’t work as intended

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

What happens when a function’s input is a different type than the output?

A

The function works, the input type can be different to the output type

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

What can be considered as output?

A

What a function displays in the console or what it returns

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

When does a variable have a local scope?

A

when we create it inside of a functions block

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

What does it mean for a variable to have a local scope?

A

We can’t access or update it outside of the function where it was created

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

What happens when we try to access a local scope variable outside of the function that created it?

A

We get an error

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

Variables created outside of a function block have a _________ scope

A

Global

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

Which variables have a global scope?

A

Variables created outside the function block

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

From where can we access a variable with a global scope?

A

from anywhere in the code

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

From where can we access a variable with a global scope?

A

from anywhere in the code

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

What kind of scope do variables created inside conditionals and loops have?

A

Local

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

When can we first access a variable, regardless of scope?

A

Only after we create it

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