Functions
function saySomething(message = 'goodbye', whisper = false) {
if (whisper) {
console.log(`%c${message}`, 'font-size: 5px;')
} else {
console.log(message)
}
}
saySomething('hello', true);
saySomething('my name is max', true);
saySomething();
// Function definition
function squared(a) {
return a * a;
}
console.log(squared(3));
// Function definition as variable
const trippled = function(b) {
return b * b * b;
}
console.log(trippled(3));
// Function definition as fat arrow
const divide = (a, b) => {
return a / b;
}
// Alternate Definiton - SHORT
// const divide = (a,b) => a / b;
console.log(divide(10, 2));
punch();
// Hoisting
function punch() {
console.log('punch');
}