From 3bf5054d61379abaf2718b7280720e3b1384a366 Mon Sep 17 00:00:00 2001 From: Brooke Shepard <121128896+loveabledanamarie@users.noreply.github.com> Date: Mon, 23 Jan 2023 11:56:03 -0700 Subject: [PATCH 1/3] Update index.js --- index.js | 97 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 84 insertions(+), 13 deletions(-) diff --git a/index.js b/index.js index e2ebbd6a5..f2b3dadc9 100644 --- a/index.js +++ b/index.js @@ -15,10 +15,19 @@ Task 1a - Voting Age (not auto tested) Do the following: 1. Create a variable called votingAge and assign it a number value + 2. Console log true if age is 18 or higher HINT: no function required -*/ +*/ +let votingAge = 18 +if (votingAge >= 18) { +console.log ("true") + +} else { +console.log ("false") +} + @@ -33,9 +42,13 @@ Do the following: HINT: no function required */ - - - +let firstThing = 2 +let secondThing = 4 +if (firstThing > secondThing) { + console.log ('true') +} +} +console.log (firstThing) /* @@ -49,8 +62,9 @@ Do the following: HINT: look up the Number method */ - - +const year = 1999" +const numYear = Number(year) +console.log (numYear) /* Task 1d - Multiply @@ -64,8 +78,10 @@ Do the following: function multiply(num1, num2){ return num1 * num2; } - - +function multiply(num1, num2) { + return num1 * num2; +} +console.log(numYear) /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 2 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ @@ -77,10 +93,14 @@ 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 } +console.log(dogYears(10)) /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 3 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ @@ -131,6 +151,28 @@ NOTE 2: This is a great time to check the tests to see what it expects, versus w function hungryDog(/*add your code here*/){ /*add your code here*/ +function hungryDog(weight, age) +if (age <1){ + if age<=.33){ + return weight *.10 + else if (age<=.58){ + return weight * .05 + } else { + return weight *.04 + } + } else { + if (weight <=5){ + return weight *.05 + } else if (weight <=10) { + return weight *.04 + + } else if (weight <=15) { + return weight *.03 + } else { + return weight *.02 + } + } +} } @@ -159,7 +201,14 @@ RULES OF THE GAME: Scissors beats Paper | Paper beats Rock | Rock beats Scissors function game(user, computer){ /*add your code here*/ } - +let cp =Math.cell(Math.random() * 3) +if (cp ===1) { + cp ='rock'; +} else if(cp === 2) { + cp ='paper' +} else { + cp = 'scissors' +} /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 5 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ @@ -176,8 +225,11 @@ Using the miles function below do the following: function miles(/*add your code here*/){ /*add your code here*/ } +function miles(kilometers){ + return (kilometers * .621371) +} - +console.log (miles(3)) //Task 5b - Centimeters to Feet /* @@ -189,8 +241,12 @@ Using the feet function below do the following: function feet(/*add your code here*/){ /*add your code here*/ -} + function feet (Centimeters){ + return Centimeters / 30.48 + } +} +console.log(feet(156)) /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 6 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ @@ -210,7 +266,9 @@ Using the annoyingSong function below do the following: function annoyingSong(/*add your code here*/){ /*add your code here*/ } - +// x = x+1 +return `${x} bottles of soda on the wall, ${x} bottles of soda, take one down pass it around ${x-1} bottles of soda on the wall` +// console.log (annoyingSong(i)) /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 7 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ @@ -229,9 +287,21 @@ Using the grade function below do the following: function grade(/*Your Code here */){ /*Your Code here */ +function greate(grade){ + if (grade >=90) { + return 'you got an A' + } else if (grade >= 80) { + return "you got an B" + } else if (grade >= 70) { + return 'you got an C' + } else if (grade >=60) { + return ' you got an D' + } else if (grade >=50) { + return 'you got an F' +} } - +console.log(grade(85)) /*💪💪💪💪💪💪💪💪💪💪 Stretch 💪💪💪💪💪💪💪💪💪💪*/ @@ -270,3 +340,4 @@ module.exports = { annoyingSong, grade } + From b723defa9c7f438e487ed2bc23d0e8f501a3aa9e Mon Sep 17 00:00:00 2001 From: Brooke Shepard <121128896+loveabledanamarie@users.noreply.github.com> Date: Mon, 23 Jan 2023 14:29:50 -0700 Subject: [PATCH 2/3] finished all tasks and corrected --- index.js | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/index.js b/index.js index f2b3dadc9..a5d2f29af 100644 --- a/index.js +++ b/index.js @@ -47,7 +47,7 @@ let secondThing = 4 if (firstThing > secondThing) { console.log ('true') } -} + console.log (firstThing) @@ -94,11 +94,9 @@ Do the following: */ -function dogYears(/*add your code here*/){ - /*add your code here*/ -function dogYears(age) +function dogYears(age) {} return age * 7 -} + console.log(dogYears(10)) @@ -151,16 +149,15 @@ NOTE 2: This is a great time to check the tests to see what it expects, versus w function hungryDog(/*add your code here*/){ /*add your code here*/ -function hungryDog(weight, age) -if (age <1){ - if age<=.33){ - return weight *.10 + + if age<=.33{ + return weight *.10} else if (age<=.58){ return weight * .05 } else { return weight *.04 } - } else { + } else if (weight <=5){ return weight *.05 } else if (weight <=10) { @@ -172,8 +169,7 @@ if (age <1){ return weight *.02 } } -} -} + @@ -222,9 +218,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){ return (kilometers * .621371) } @@ -242,9 +238,8 @@ Using the feet function below do the following: function feet(/*add your code here*/){ /*add your code here*/ - function feet (Centimeters){ - return Centimeters / 30.48 - } + + } console.log(feet(156)) @@ -267,6 +262,7 @@ function annoyingSong(/*add your code here*/){ /*add your code here*/ } // x = x+1 + return `${x} bottles of soda on the wall, ${x} bottles of soda, take one down pass it around ${x-1} bottles of soda on the wall` // console.log (annoyingSong(i)) @@ -289,8 +285,7 @@ function grade(/*Your Code here */){ /*Your Code here */ function greate(grade){ if (grade >=90) { - return 'you got an A' - } else if (grade >= 80) { + return "you got an B" } else if (grade >= 70) { return 'you got an C' From 4e2c531f96f374bd49cd10fc57056b4b25f248ef Mon Sep 17 00:00:00 2001 From: Brooke Shepard <121128896+loveabledanamarie@users.noreply.github.com> Date: Mon, 23 Jan 2023 20:27:53 -0700 Subject: [PATCH 3/3] finished all tasks --- index.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index a5d2f29af..fc61283d1 100644 --- a/index.js +++ b/index.js @@ -62,7 +62,7 @@ Do the following: HINT: look up the Number method */ -const year = 1999" +const year = "1999" const numYear = Number(year) console.log (numYear) @@ -94,8 +94,9 @@ Do the following: */ -function dogYears(age) {} -return age * 7 +function dogYears(age) { + +} return age * 7 console.log(dogYears(10)) @@ -146,8 +147,7 @@ NOTE 2: This is a great time to check the tests to see what it expects, versus w Notice the expected and received, expected is what the test is looking for, and received is what was actually returned from this function. You can also see it's passing in two values, the number 4 and the number 1. So, on this one test, the weight would be 4 pounds, and the age would be 1 years old. It's expecting your function to return a decimal number of 0.2 */ - -function hungryDog(/*add your code here*/){ +function hungryDog(weight,age){} /*add your code here*/ if age<=.33{ @@ -157,8 +157,7 @@ function hungryDog(/*add your code here*/){ } else { return weight *.04 } - } else - if (weight <=5){ + else if (weight <=5){ return weight *.05 } else if (weight <=10) { return weight *.04 @@ -194,6 +193,15 @@ Use the game function below to do the following: RULES OF THE GAME: Scissors beats Paper | Paper beats Rock | Rock beats Scissors | Or there's a tie */ +let cp =Math.cell(Math.random() * 3) +if (cp ===1) { + cp ='rock'; +} else if(cp === 2) { + cp ='paper' +} else { + cp = 'scissors' +} + function game(user, computer){ /*add your code here*/ } @@ -212,6 +220,7 @@ if (cp ===1) { //Metric Converter //Task 5a - Kilometers to Miles /* + Using the miles function below do the following: 1. Receive a number of kilometers 2. Convert the number of kiolmeters received to miles @@ -219,7 +228,7 @@ Using the miles function below do the following: */ - /*add your code here*/ + function miles(kilometers){ return (kilometers * .621371)