Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q2.2 #2

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 114 additions & 11 deletions exercises.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ console.log(testGreeting); // printing the output value of the function.
* These two variables will be used to invoke the functions #2 - #5.
*/


var bango1 = 10;
var bango2 = 5;

/*
* #2
Expand All @@ -44,6 +45,11 @@ console.log(testGreeting); // printing the output value of the function.
* Console.log `sum` to test your code.
*/

function add(num1 , num2){
return num1+num2;
}
var sum = add(bango1 , bango2);
console.log(sum);


/*
Expand All @@ -60,7 +66,11 @@ console.log(testGreeting); // printing the output value of the function.
* Console.log `difference` to test your code.
*/


function subtract(num1 , num2){
return num1-num2;
}
var difference = subtract(bango1 , bango2);
console.log(difference);

/*
* #4
Expand All @@ -76,7 +86,11 @@ console.log(testGreeting); // printing the output value of the function.
* Console.log `product` to test your code.
*/


function multiply(num1 , num2){
return num1*num2;
}
var product = multiply(bango1 , bango2);
console.log(product);

/*
* #5
Expand All @@ -92,7 +106,11 @@ console.log(testGreeting); // printing the output value of the function.
* Console.log `quotient` to test your code.
*/


function divide(num1 , num2){
return num1/num2
}
var quotient = divide(bango1 , bango2);
console.log(quotient);

/*
* #6
Expand All @@ -106,7 +124,11 @@ console.log(testGreeting); // printing the output value of the function.
* Console.log your result.
*/


function checkSum(x){
return "Mariah Cary has been married " + x + " amount of times."
}
var daDiva = checkSum(sum);
console.log(daDiva);

/*
* #7
Expand All @@ -120,7 +142,11 @@ console.log(testGreeting); // printing the output value of the function.
* Console.log your results.
*/


function checkDifference(x){
return "Last night I dreamt that I ate " + x + " Taco Bell soft tacos."
}
var difference = checkDifference(10);
console.log(difference);

/*
* #8
Expand All @@ -133,7 +159,12 @@ console.log(testGreeting); // printing the output value of the function.
* Console.log your result.
*/

function checkProduct(){
return sum * product;
}

var showResult = checkProduct();
console.log("showResult" , showResult);

/*
* #9
Expand All @@ -146,6 +177,12 @@ console.log(testGreeting); // printing the output value of the function.
* Console.log your result.
*/

function checkQuotient(){
return product * quotient
}
var showResult = checkQuotient();
console.log("showResult" , showResult);

/*
* Declare three variables
* @variable Datatype: Number `bango3`
Expand All @@ -166,7 +203,16 @@ console.log(testGreeting); // printing the output value of the function.
* Console.log your result.
*/

var bango3 = 2;
var bango4 = 4;
var bango5 = 5;

function addThenSubtract(num1, num2, num3){
var sum = add(num1 , num2);
return subtract(sum , num3);
}
var showResult = addThenSubtract();
console.log("showResult" , showResult);

/*
* #11
Expand All @@ -182,7 +228,12 @@ console.log(testGreeting); // printing the output value of the function.
* Console.log your result.
*/


function multiplyThenDivide(num1, num2, num3){
var product = multiply(num1, num2);
return divide(product , num3);
}
var showResult = multiplyThenDivide();
console.log("showResult", showResult);

/*
* #12
Expand All @@ -196,6 +247,11 @@ console.log(testGreeting); // printing the output value of the function.
* This function `returns` back a string which represents someone's full name. Invoke this function by passing in your first and last name into the function. Store the return value into a variable named `myFullName` and console.log this variable to show your result.
*/

function createFullName(firstName , lastName){
return firstName + lastName;
}
var myFullName = createFullName("Nicholas " , "Gambino ");
console.log(myFullName);


/*
Expand All @@ -213,6 +269,22 @@ console.log(testGreeting); // printing the output value of the function.
*/


//Option 1//

//function eatFood(firstName, lastName, food){
// var food = "Won Ton Soup";
// return myFullName + "eats " + food + " everyday for breakfast.";
//}
//var myBreakfast = eatFood(myFullName);
//console.log(myBreakfast);

//Option 2//

function eatFood(firstName, lastName, food){
return myFullName + "eats " + food + " everday for breakfast";
}
console.log(eatFood("Biggie" , "Smalls" , "Won Ton Soup"));


/************** ENGAGE HYPERDRIVE **************/
/* No more training wheels! For the exercises #14-18, use the experience you've
Expand All @@ -227,7 +299,12 @@ console.log(testGreeting); // printing the output value of the function.
* Console.log your result.
*/


function shoeSize(inches){
var cmConverter = 2.54;
return multiply(cmConverter , inches);
}
var shoeSizeInInches = shoeSize(10)
console.log(shoeSizeInInches);

/*
* #15
Expand All @@ -239,7 +316,11 @@ console.log(testGreeting); // printing the output value of the function.
* Example output: "BELIEVE YOU CAN AND YOU'RE HALFWAY THERE."
*/


function allCaps(str){
return str.toUpperCase();
}
var string1 = allCaps("believe you can and you're halfway there");
console.log(string1);

/*
* #16
Expand All @@ -249,6 +330,11 @@ console.log(testGreeting); // printing the output value of the function.
* Console.log your result.
*/

function oneCap(str){
return str.charAt(0).toUpperCase() + str.slice(1);
}
var string2 = oneCap("believe you can and you're halfway there");
console.log(string2);


/*
Expand All @@ -262,6 +348,16 @@ console.log(testGreeting); // printing the output value of the function.
* Store the return value to a variable named `canDrink`. Console.log your result.
*/

function verifyDrinkingAge(age){
var drinkingAge = 20
if(age > drinkingAge){
return true;
} else{
return false;
}
}
var canDrink = verifyDrinkingAge(25);
console.log(canDrink);


/**
Expand All @@ -270,8 +366,15 @@ console.log(testGreeting); // printing the output value of the function.
* Create a function named throwParty. This function will check the value stored in the `canDrink` variable in the previous exercise. If the value is true, it will return the message "Cheee Hoo! We going to da party!" If false, then it will return the message "Meh, see you at Starbucks." Store the return value to a variable named `canParty`. Console.log your result.
*/



function throwParty(){
if(true){
return "Cheee Hoo! We going to da party!"
} else{
return "Meh, see you at Starbucks."
}
}
var canParty = throwParty(canDrink);
console.log(canParty);