From 8af20ab5da238757ad45913f331718f7aec7398b Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 3 Nov 2020 18:47:17 -0600 Subject: [PATCH 1/2] got some, struggled with beginning --- index.js | 70 +++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 21 deletions(-) diff --git a/index.js b/index.js index 998736e9a..6efb37d86 100644 --- a/index.js +++ b/index.js @@ -30,8 +30,10 @@ Do the following: HINT: no function required */ +// let a = 1; +// let b = 2; - +// if () @@ -46,7 +48,7 @@ Do the following: HINT: look up the Number method */ - +// return Number("1999"); /* @@ -58,10 +60,10 @@ Do the following: 3. Multiply a and b and return the answer */ -function multiply(/*add your code here*/){ - /*add your code here*/ +function multiply(a , b){ + return (a * b) } - +console.log(multiply(3,4)) /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 2 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ @@ -74,10 +76,10 @@ Do the following: 3. Return the newly calculated age */ -function dogYears(/*add your code here*/){ - /*add your code here*/ +function dogYears(myAge){ + return (myAge * 7); } - +console.log(dogYears(25)); /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 3 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ @@ -107,10 +109,26 @@ Use the hungryDog function and feeding requirements below to do the following: NOTE: If done correctly, a weight of 15 lbs and age of 1 year would return 0.44999999999999996 */ -function hungryDog(/*add your code here*/){ - /*add your code here*/ +function hungryDog(weight,age ){ + if (age >= 1){ + if (weight <= 5){ + return (weight * .05); + } else if (weight > 5 && weight <= 10){ + return (weight * .04); + } else if (weight > 10 && weight <=15){ + return (weight * .03); + } else if (weight > 15){ + return (weight *.02); + } + } else if (age >= .1666 && age < .333){ + return (weight * .1) + } else if (age >= .3334 && age < .583){ + return (weight * .05); + } else if (age >= .584 && age < 1){ + return (weight * .04); + } } - +console.log(hungryDog(15,1)); /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 4 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ @@ -127,7 +145,7 @@ Use the game function below to do the following: HINT: While you can complete this with only conditionals based on strings, it may help to equate choice to a number when using Math.random() */ -function game(/*add your code here*/){ +function game(choice,){ /*add your code here*/ } @@ -144,10 +162,10 @@ Using the miles function below do the following: 3. Return the number of miles */ -function miles(/*add your code here*/){ - /*add your code here*/ +function miles(numKM){ + return (numKM * .621371) } - +console.log(miles(5)) //Task 5b - Feet to CM @@ -158,10 +176,10 @@ Using the feet function below do the following: 3. Return number of feet */ -function feet(/*add your code here*/){ - /*add your code here*/ +function feet(numCM){ + return (numCM / 30.48 ) } - + console.log(feet(100)) /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 6 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ @@ -194,11 +212,21 @@ Using the grade function below do the following: below 60 = F */ -function grade(/*add your code here*/){ - /*add your code here*/ +function grade(score){ + if (score >= 90){ + return 'A' + } else if (score >= 80){ + return 'you got a B' + } else if (score >= 70){ + return 'C' + } else if (score >= 60){ + return 'D' + } else { + return 'F' + } } - + console.log(grade(75)) From a3e64d8a0416c0f653dada067dc4b3a06a8117a8 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 3 Nov 2020 18:57:29 -0600 Subject: [PATCH 2/2] test --- index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 6efb37d86..2d83221e0 100644 --- a/index.js +++ b/index.js @@ -48,7 +48,8 @@ Do the following: HINT: look up the Number method */ -// return Number("1999"); +let num = '1999'; +returnNumber(num); /* @@ -191,7 +192,7 @@ Using the annoyingSong function below do the following: 2. At each iteration, it should return this string: "(number) bottles of soda on the wall, (number) bottles of soda, take one down pass it around (number left over) bottles of soda on the wall" */ - +dsf function annoyingSong(/*add your code here*/){ /*add your code here*/ }