function getReminder() {
console.log('Water the plants.')
}
function greetInSpanish() {
console.log('Buenas Tardes.')
}
// function with parameter
function sayThanks(name) {
console.log('Thank you for your purchase ' + name + '! We appreciate your business.');
}
// default parameter value
function makeShoppingList(item1 = 'milk', item2='bread', item3='eggs'){
console.log(`Remember to buy ${item1}`);
console.log(`Remember to buy ${item2}`);
console.log(`Remember to buy ${item3}`);
}
// function return value
function monitorCount(rows, columns) {
return rows * columns;
}
const numOfMonitors = monitorCount(5,4)
console.log(numOfMonitors)
// function calls function
function monitorCount(rows, columns) {
return rows * columns;
}
function costOfMonitors(rows, columns) {
return monitorCount(rows, columns) * 200;
}
const totalCost = costOfMonitors(5, 4)
console.log(totalCost)
const plantNeedsWater = function(day) {
if (day === 'Wednesday') return true;
else return false;
}; // anonymous function
plantNeedsWater('Tuesday');
console.log(plantNeedsWater('Tuesday'))
// arrow function
const plantNeedsWater = (day) => {
return day === 'Wednesday' ? true : false;
};
const plantNeedsWater = day => day === 'Wednesday' ? true : false;
const getUserChoice = userInput => {
userInput = userInput.toLowerCase();
if (userInput === 'rock' || userInput === 'paper' || userInput === 'scissors') return userInput;
else console.log('Invalid Input');
};
function getComputerChoice() {
choice = Math.floor(Math.random() * 3);
switch (choice) {
case 0: return 'rock'; break;
case 1: return 'paper'; break;
case 2: return 'scissors'; break;
}
}
function determineWinner(userChoice, computerChoice) {
if (userChoice === computerChoice) return 'Tie';
else if (userChoice === 'rock' && computerChoice === 'scissors') return 'You Win. FUCK YOU BITCH';
else if (userChoice === 'scissors' && computerChoice === 'paper') return 'You Win. FUCK YOU BITCH';
else if (userChoice === 'paper' && computerChoice === 'rock') return 'You Win. FUCK YOU BITCH';
else return 'You Lose! Such a LOOOOOSER!!'
}
let user = getUserChoice('Rock');
let comp = getComputerChoice();
console.log(determineWinner(user, comp))