Lesson 3: Introduction to Functions Flashcards

1
Q

Some Function Concepts:

A
  • Functions are reusable.
  • Functions make code easier to debug and maintain.
  • Functions need to be called to run its statements.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Show how a function can be used to handle events:

A

onclick=”sayHello();”

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

What is a Method?

A

Functions that “belong” to a specific object.

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

Write a Return Value:

A
function hello () {
return 'hello world!';
}
const message = hello();
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are Parameters and arguments?

A

Terms used to represent data provided for the functions as inputs.

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

When a function is invoked, what are the inputs provided called?

A

Arguments.

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

When are Parameters set?

A

When the function is defined.

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

Show a function call being used for another function call:

A
let wall = getArea(3, 5);
alert(wall);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is an Anonymous Function?

A

A function that doesn’t have a name.

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

Show an example of an Anonymous Function:

A
const goodbye = function() {
console.log('goodbye world');
};
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

General Functions Syntax:

A
function sayHello() {
alert("Hello");
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Show a function that calculates the cube of a number and displays the result”

A
function cube (x) {
alert(x * x * x);
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly