From 8cf4264c93c023187c04817ca30a8ef1aa4e43bc Mon Sep 17 00:00:00 2001 From: Nicholas Gambino Date: Sun, 7 Jan 2018 19:42:52 -1000 Subject: [PATCH 01/14] Q1 --- exercises.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises.js b/exercises.js index e3ea79a..c191e8d 100644 --- a/exercises.js +++ b/exercises.js @@ -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 @@ -77,7 +78,6 @@ console.log(testGreeting); // printing the output value of the function. */ - /* * #5 * Function - divide From 97496ee925b728f6de3bb43b9626f326ef1edc90 Mon Sep 17 00:00:00 2001 From: Nicholas Gambino Date: Sun, 7 Jan 2018 19:49:08 -1000 Subject: [PATCH 02/14] Q2 --- exercises.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/exercises.js b/exercises.js index c191e8d..1f7d9f6 100644 --- a/exercises.js +++ b/exercises.js @@ -45,6 +45,11 @@ var bango2 = 5; * Console.log `sum` to test your code. */ +function add(num1 , num2){ + return num1+num2; +} +var testadd = add(5 , 10); +console.log(testadd); /* From cc159a968475623288ae1a4ca29d71a865e4af4f Mon Sep 17 00:00:00 2001 From: Nicholas Gambino Date: Sun, 7 Jan 2018 19:51:27 -1000 Subject: [PATCH 03/14] Q2 --- exercises.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises.js b/exercises.js index 1f7d9f6..6463e47 100644 --- a/exercises.js +++ b/exercises.js @@ -48,8 +48,8 @@ var bango2 = 5; function add(num1 , num2){ return num1+num2; } -var testadd = add(5 , 10); -console.log(testadd); +var sum = add(5 , 10); +console.log(sum); /* From 3d72b1e75d32de7f4c4825b5434875ac526405d5 Mon Sep 17 00:00:00 2001 From: Nicholas Gambino Date: Sun, 7 Jan 2018 19:58:10 -1000 Subject: [PATCH 04/14] Q2.2 --- exercises.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises.js b/exercises.js index 6463e47..2d4ee8a 100644 --- a/exercises.js +++ b/exercises.js @@ -48,7 +48,7 @@ var bango2 = 5; function add(num1 , num2){ return num1+num2; } -var sum = add(5 , 10); +var sum = add(bango1 , bango2); console.log(sum); From b6600fa5b7ac7be1d34f303fa9f16eda8e9c7849 Mon Sep 17 00:00:00 2001 From: Nicholas Gambino Date: Sun, 7 Jan 2018 20:09:17 -1000 Subject: [PATCH 05/14] Q3 --- exercises.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/exercises.js b/exercises.js index 2d4ee8a..02ee294 100644 --- a/exercises.js +++ b/exercises.js @@ -66,7 +66,11 @@ console.log(sum); * Console.log `difference` to test your code. */ - +function subtract(num1 , num2){ + return num1-num2; +} +var subtract = subtract(bango1 , bango2); +console.log(subtract); /* * #4 From 20d53c8fed81392f0cd24c034149742536b499f1 Mon Sep 17 00:00:00 2001 From: Nicholas Gambino Date: Sun, 7 Jan 2018 20:13:54 -1000 Subject: [PATCH 06/14] Q4 --- exercises.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/exercises.js b/exercises.js index 02ee294..86b0b86 100644 --- a/exercises.js +++ b/exercises.js @@ -69,8 +69,8 @@ console.log(sum); function subtract(num1 , num2){ return num1-num2; } -var subtract = subtract(bango1 , bango2); -console.log(subtract); +var difference = subtract(bango1 , bango2); +console.log(difference); /* * #4 @@ -86,6 +86,11 @@ console.log(subtract); * Console.log `product` to test your code. */ +function multiply(num1 , num2){ + return num1*num2 +} +var product = multiply(bango1 , bango2); +console.log(product); /* * #5 From b0549e408d0617eaf768c97a842918b2bd731bad Mon Sep 17 00:00:00 2001 From: Nicholas Gambino Date: Sun, 7 Jan 2018 20:20:06 -1000 Subject: [PATCH 07/14] Q5 --- exercises.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/exercises.js b/exercises.js index 86b0b86..839c7d5 100644 --- a/exercises.js +++ b/exercises.js @@ -87,7 +87,7 @@ console.log(difference); */ function multiply(num1 , num2){ - return num1*num2 + return num1*num2; } var product = multiply(bango1 , bango2); console.log(product); @@ -106,7 +106,11 @@ console.log(product); * Console.log `quotient` to test your code. */ - +function divide(num1 , num2){ + return num1/num2 +} +var quotient = divide(bango1 , bango2); +console.log(quotient); /* * #6 From 3d35ac5f31f838e0a4b945ef179e4f3d96add986 Mon Sep 17 00:00:00 2001 From: Nicholas Gambino Date: Sun, 7 Jan 2018 20:27:44 -1000 Subject: [PATCH 08/14] Q6 --- exercises.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/exercises.js b/exercises.js index 839c7d5..5fb749e 100644 --- a/exercises.js +++ b/exercises.js @@ -124,7 +124,11 @@ console.log(quotient); * Console.log your result. */ - +function checkSum(x){ + return "Mariah Cary has been married " + x + " amount of times." +} +var daDiva = checkSum(2); +console.log(daDiva); /* * #7 From c6c55cfdb99f4d561543782b0ac85583348cb227 Mon Sep 17 00:00:00 2001 From: Nicholas Gambino Date: Sun, 7 Jan 2018 20:32:22 -1000 Subject: [PATCH 09/14] Q7 --- exercises.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/exercises.js b/exercises.js index 5fb749e..1127462 100644 --- a/exercises.js +++ b/exercises.js @@ -142,7 +142,11 @@ console.log(daDiva); * 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 From e04ae998808d92a1dc02fa4dc826af74114775e8 Mon Sep 17 00:00:00 2001 From: Nicholas Gambino Date: Sun, 7 Jan 2018 20:49:08 -1000 Subject: [PATCH 10/14] Q8 --- exercises.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/exercises.js b/exercises.js index 1127462..d38c138 100644 --- a/exercises.js +++ b/exercises.js @@ -159,7 +159,12 @@ console.log(difference); * Console.log your result. */ +function checkProduct(){ + return sum * product; +} +var showResult = checkProduct(); +console.log("showResult" , showResult); /* * #9 From 7e6b5398ee61667251a18447ebb4a1451d9d88f3 Mon Sep 17 00:00:00 2001 From: Nicholas Gambino Date: Sun, 7 Jan 2018 20:53:32 -1000 Subject: [PATCH 11/14] exercises.js --- exercises.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/exercises.js b/exercises.js index d38c138..b18da21 100644 --- a/exercises.js +++ b/exercises.js @@ -177,6 +177,12 @@ console.log("showResult" , showResult); * Console.log your result. */ +function checkQuotient(){ + return product * quotient +} +var showResult = checkQuotient(); +console.log("showResult" , showResult); + /* * Declare three variables * @variable Datatype: Number `bango3` From d6b4d3e8ff839921fa5566e4f9e344ea90f10da6 Mon Sep 17 00:00:00 2001 From: Nicholas Gambino Date: Sun, 7 Jan 2018 21:06:22 -1000 Subject: [PATCH 12/14] q10 --- exercises.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/exercises.js b/exercises.js index b18da21..932f735 100644 --- a/exercises.js +++ b/exercises.js @@ -203,7 +203,16 @@ console.log("showResult" , showResult); * Console.log your result. */ +var bango3 = 2; +var bango4 = 4; +var bango5 = 5; +function addThenSubtract(){ + var sum = add(bango3 , bango4); + return subtract(sum , bango5); +} +var showResult = addThenSubtract(); +console.log("showResult" , showResult); /* * #11 From 6163b3fe5db4e63d4d8d38359e84a54bb6d70eeb Mon Sep 17 00:00:00 2001 From: Nicholas Gambino Date: Sun, 7 Jan 2018 22:23:10 -1000 Subject: [PATCH 13/14] the rest of the problems --- exercises.js | 67 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 62 insertions(+), 5 deletions(-) diff --git a/exercises.js b/exercises.js index 932f735..41897e6 100644 --- a/exercises.js +++ b/exercises.js @@ -228,7 +228,12 @@ console.log("showResult" , showResult); * Console.log your result. */ - +function multiplyThenDivide(){ + var product = multiply(bango3, bango4); + return divide(product , bango5); +} +var showResult = multiplyThenDivide(); +console.log("showResult", showResult); /* * #12 @@ -242,6 +247,11 @@ console.log("showResult" , showResult); * 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); /* @@ -259,6 +269,22 @@ console.log("showResult" , showResult); */ +//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 @@ -273,7 +299,12 @@ console.log("showResult" , showResult); * Console.log your result. */ - +function shoeSize(inches){ + var cmConverter = 2.54; + return multiply(cmConverter , inches); +} +var shoeSizeInInches = shoeSize(10) +console.log(shoeSizeInInches); /* * #15 @@ -285,7 +316,11 @@ console.log("showResult" , showResult); * 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 @@ -295,6 +330,11 @@ console.log("showResult" , showResult); * 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); /* @@ -308,6 +348,16 @@ console.log("showResult" , showResult); * 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); /** @@ -316,8 +366,15 @@ console.log("showResult" , showResult); * 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); From 64a316673483e0f71196be25e274454848ca4341 Mon Sep 17 00:00:00 2001 From: Nicholas Gambino Date: Mon, 8 Jan 2018 20:13:13 -1000 Subject: [PATCH 14/14] js-functions.js --- exercises.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/exercises.js b/exercises.js index 41897e6..1efb184 100644 --- a/exercises.js +++ b/exercises.js @@ -127,7 +127,7 @@ console.log(quotient); function checkSum(x){ return "Mariah Cary has been married " + x + " amount of times." } -var daDiva = checkSum(2); +var daDiva = checkSum(sum); console.log(daDiva); /* @@ -207,9 +207,9 @@ var bango3 = 2; var bango4 = 4; var bango5 = 5; -function addThenSubtract(){ - var sum = add(bango3 , bango4); - return subtract(sum , bango5); +function addThenSubtract(num1, num2, num3){ + var sum = add(num1 , num2); + return subtract(sum , num3); } var showResult = addThenSubtract(); console.log("showResult" , showResult); @@ -228,9 +228,9 @@ console.log("showResult" , showResult); * Console.log your result. */ -function multiplyThenDivide(){ - var product = multiply(bango3, bango4); - return divide(product , bango5); +function multiplyThenDivide(num1, num2, num3){ + var product = multiply(num1, num2); + return divide(product , num3); } var showResult = multiplyThenDivide(); console.log("showResult", showResult);