- How do we even do it?
- What was your result?
//FUNCTION EXPRESSION:
var logStuff = function(param) {
console.log(`${param} was passed in`);
};
//FUNCTION DECLARATION
function multiply(num, secondNum) {
return num * secondNum;
};
//****IMPORTANT: Function hoisting only works with function declaration and not with function expression.
//BASIC SYNTAX
(arg1, arg2) => {
// function body here
}
//OR//
let multiply = (arg1, arg2) => return arg1 * arg2;
//IF THERE'S ONLY 1 ARGUMENT:
arg1 => {alert(arg1)}
//OR//
arg1 => alert(arg1);
//IF THERE ARE NO ARGUMENTS:
() => {
console.log('Hello there!');
}
On your day5 branch, write a function that calculates a dog's age. It should:
Make sure you're checking for edge-cases!
Now, write a function that tells you what a "lifetime supply" will be for any product. It should:
There is a basic, but important difference
We will cover this more in-depth in a future class, but for now, remember the difference.
On your takehome-day5 branch write a program that uses functions to: