From c1274ea61dd74d3f2c93c69167128fd358a01b71 Mon Sep 17 00:00:00 2001 From: Justin Benz Date: Tue, 6 Oct 2020 19:35:27 -0400 Subject: [PATCH 1/4] Finished Project --- index.js | 108 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 85 insertions(+), 23 deletions(-) diff --git a/index.js b/index.js index 998736e9a..fa779255d 100644 --- a/index.js +++ b/index.js @@ -17,7 +17,13 @@ Do the following: HINT: no function required */ - +const votingAge = 18; +function vaCheck(votingAge){ + if(votingAge >= 18){ + return true; + } +} +vaCheck(votingAge); /* @@ -31,7 +37,11 @@ Do the following: HINT: no function required */ - +let value1 = 2; +let value2 = 3; +if(5 > 2){ + value1 = value1 + value2; +} @@ -58,8 +68,8 @@ 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; } @@ -74,8 +84,8 @@ Do the following: 3. Return the newly calculated age */ -function dogYears(/*add your code here*/){ - /*add your code here*/ +function dogYears(Age){ + return Age * 7; } @@ -107,9 +117,27 @@ 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 >= 6 && weight <= 10){ + return weight * .04; + } else if(weight >= 11 && weight <= 15){ + return weight * .03; + } else if(weight >= 15){ + return weight * .02; + } + } else if(age <= 1){ + if(weight >= 2 && weight <= 4){ + return weight * .1; + } else if (weight >= 4 && weight <= 7){ + return weight * .05; + } else if (weight >= 7 && weight <= 12){ + return weight * .04; + } } +} @@ -126,9 +154,24 @@ 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*/){ - /*add your code here*/ +let randomNum = Math.random(); +let cChoice; +if (randomNum <= .33){ + cChoice = 'rock'; +} else if(randomNum <= .66){ + cChoice = 'paper'; +} else{ + cChoice = 'scissors'; +} +function game(choice, cChoice){ + if (choice === 'rock' && cChoice === 'scissors' || choice === 'scissors' && cChoice ==='paper' || choice ==='paper' && cChoice === 'rock'){ + return "you win!"; + }else if (choice =='rock' && cChoice === 'paper' || choice === 'paper' && cChoice === 'scissors' || choice === 'scissors' && cChoice === 'rock'){ + return "you lose!"; + } + else{ + return "it's a tie"; + } } @@ -144,8 +187,9 @@ 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(kilometers){ + let MetricConverter = kilometers * 0.621371; + return MetricConverter; } @@ -158,8 +202,9 @@ 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(centimeters){ + let fToCM = centimeters / 30.48; + return fToCM; } @@ -174,8 +219,10 @@ Using the annoyingSong function below do the following: "(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" */ -function annoyingSong(/*add your code here*/){ - /*add your code here*/ +function annoyingSong(startingNumber){ + for(let i = 0; i < startingNumber; i++){ + return `${startingNumber} ` + 'bottles of soda on the wall,' + ` ${startingNumber} ` + 'bottles of soda, take one down pass it around'+ ` ${startingNumber - 1} ` + 'bottles of soda on the wall'; + } } @@ -194,9 +241,23 @@ Using the grade function below do the following: below 60 = F */ -function grade(/*add your code here*/){ - /*add your code here*/ +function grade(score){ + let cvtGrade; + if(score >= 90 && score <= 100){ + cvtGrade = 'A'; + } else if(score >= 80 && score <= 89){ + cvtGrade = 'B'; + } else if(score >= 70 && score <= 79){ + cvtGrade = 'C'; + } else if(score >= 60 && score <= 69){ + cvtGrade = 'D'; + } else{ + cvtGrade = 'F'; + } + return 'you got a' + ` ${cvtGrade}` } + + grade(92); @@ -214,10 +275,11 @@ Using the vowelCounter function below do the following: HINT - try looking up the .includes() method */ - -function vowelCounter(/*add your code here*/) { - /*add your code here*/ -} +// const listOfVowels = ['a', 'e', 'i', 'o', 'u'] +// function vowelCounter(Vowel) { +// Vowel = Vowel.length() +// return Vowel +// } From 8c0b67bc7df56a02f4a431f7b4e9a44efad4bc99 Mon Sep 17 00:00:00 2001 From: Justin Benz Date: Tue, 6 Oct 2020 19:40:36 -0400 Subject: [PATCH 2/4] Create a CodeGrade submission From 150ef8d90ea99de04092c2404822dbe238005783 Mon Sep 17 00:00:00 2001 From: Justin Benz Date: Tue, 6 Oct 2020 19:46:48 -0400 Subject: [PATCH 3/4] Create a CodeGrade submission From 1fecd17f0dbd17797be747abec8540ca835c2aaf Mon Sep 17 00:00:00 2001 From: Justin Benz Date: Tue, 6 Oct 2020 19:50:47 -0400 Subject: [PATCH 4/4] Create a CodeGrade submission --- index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/index.js b/index.js index fa779255d..1c4ef3a03 100644 --- a/index.js +++ b/index.js @@ -254,10 +254,9 @@ function grade(score){ } else{ cvtGrade = 'F'; } - return 'you got a' + ` ${cvtGrade}` + return `you got a ${cvtGrade}` } - grade(92);