James Gibson
Describe why a function is useful
Label the syntax of a function
Declare and invoke a function
Use the keyword return
A reusable sequence of instructions that achieve a specific task
Reproducable
const hello = (name) => {
console.log(`Hello, ${name}`);
};
hello('James')
"Hello, James"Talk to your neighbor
In your own words, describe the purpose of a function
Give an example of a task to use a function for
Questions?
const hello = () => {
console.log('Hello World');
};Arrow Syntax
Your instructions go here.
Parens
Function name
^
ES6
function multiply(a, b) {
return a * b;
};Parameters
return keyword
^
ES5
function keyword
Name
multiply(3, 4)
// 12Arguments
Invoking a function
Function name
How the returned or logged information is shown in documentation
const multiply = (a, b) => {
return a * b;
};Identify and label each part of the function
Name
Parameters
Arrow Syntax
return keyword
Let's go code some stuff!
const sum = (a, b) => {
return a + b;
};
sum(5,3) // 8const multiply = (a, b) => {
return a * b;
};
multiply(2, 3) // 6const arrayLength = (array) => {
return array.length;
};
arrayLength([1,2,3]) // 3
Define and invoke a function named "arrayLength" that accepts an array as its argument and returns the length of that array.
const division = (a, b) => {
return a / b;
};
division(6, 3) // 2What is a function?
What part of a function is this?
Describe this line
Why do we use "return"?