From 4e6173f771b70b450c2bd84eebcccf0b25ef1e29 Mon Sep 17 00:00:00 2001 From: Rakan Abulathou Date: Mon, 24 Apr 2023 02:34:08 -0400 Subject: [PATCH 1/4] completed task 1 --- index.js | 79 +++++++++++++++++++++++--------------------------------- 1 file changed, 32 insertions(+), 47 deletions(-) diff --git a/index.js b/index.js index e2ebbd6a5..54dad0b9a 100644 --- a/index.js +++ b/index.js @@ -19,8 +19,10 @@ Do the following: HINT: no function required */ - - +const votingAge = 18; +if (votingAge >= 18) { + console.log("true"); +} /* Task 1b - Values (not auto tested) @@ -33,11 +35,12 @@ Do the following: HINT: no function required */ - - - - - +let firstThing = 25; +const secondThing = 2; +if (firstThing !== secondThing) { + firstThing *= secondThing; +} +console.log(firstThing); /* Task 1c - Convert Strings to Numbers (not auto tested) @@ -48,10 +51,9 @@ Do the following: HINT: look up the Number method */ - - - - +let year = "1999"; +let intYear = Number(year); +console.log(intYear); /* Task 1d - Multiply @@ -61,11 +63,10 @@ Do the following: 3. Multiply a and b and return the answer */ -function multiply(num1, num2){ +function multiply(num1, num2) { return num1 * num2; } - - +console.log(multiply(2, 6)); /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 2 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ @@ -77,12 +78,10 @@ Do the following: 3. Return the newly calculated age */ -function dogYears(/*add your code here*/){ +function dogYears(/*add your code here*/) { /*add your code here*/ } - - /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 3 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ //Dog feeder - Depending on their weight and age, we need to know how many pounds of food to feed our dog each day! @@ -127,14 +126,12 @@ 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(/*add your code here*/) { /*add your code here*/ } - - /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 4 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ // Rock, Paper, Scissors - Let's play against the computer! @@ -156,16 +153,14 @@ 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 */ -function game(user, computer){ +function game(user, computer) { /*add your code here*/ } - - /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 5 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ -//Metric Converter -//Task 5a - Kilometers to Miles +//Metric Converter +//Task 5a - Kilometers to Miles /* Using the miles function below do the following: 1. Receive a number of kilometers @@ -173,12 +168,10 @@ Using the miles function below do the following: 3. Return the number of miles */ -function miles(/*add your code here*/){ +function miles(/*add your code here*/) { /*add your code here*/ } - - //Task 5b - Centimeters to Feet /* Using the feet function below do the following: @@ -187,12 +180,10 @@ Using the feet function below do the following: 3. Return number of feet */ -function feet(/*add your code here*/){ +function feet(/*add your code here*/) { /*add your code here*/ } - - /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 6 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ // Let's Sing 99 Bottles of Soda on the Wall! @@ -207,11 +198,10 @@ Using the annoyingSong function below do the following: 4. Each time the annoyingSong is run from this loop, it should console.log the string that was returned. */ -function annoyingSong(/*add your code here*/){ - /*add your code here*/ +function annoyingSong(/*add your code here*/) { + /*add your code here*/ } - /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 7 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ //Grade Calculator @@ -227,12 +217,10 @@ Using the grade function below do the following: below should return 'you got an F' */ -function grade(/*Your Code here */){ -/*Your Code here */ +function grade(/*Your Code here */) { + /*Your Code here */ } - - /*💪💪💪💪💪💪💪💪💪💪 Stretch 💪💪💪💪💪💪💪💪💪💪*/ //Vowel Counter - How many vowels are there? @@ -245,17 +233,14 @@ HINT - you may need to study tomorrow's content on arrays HINT - try looking up the .includes() method */ - function vowelCounter(/*add your code here*/) { /*add your code here*/ } - - /*🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑 Please do not modify anything below this line 🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑*/ -function foo(){ - console.log('its working'); - return 'bar'; +function foo() { + console.log("its working"); + return "bar"; } foo(); /*🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑 Don't touch the code after this line! 🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑*/ @@ -268,5 +253,5 @@ module.exports = { miles, feet, annoyingSong, - grade -} + grade, +}; From 19a24578915de395a1b72b3452eb702efe25a89f Mon Sep 17 00:00:00 2001 From: Rakan Abulathou Date: Mon, 24 Apr 2023 03:17:08 -0400 Subject: [PATCH 2/4] completed task 2 --- index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 54dad0b9a..6f12c5d7e 100644 --- a/index.js +++ b/index.js @@ -78,10 +78,13 @@ Do the following: 3. Return the newly calculated age */ -function dogYears(/*add your code here*/) { - /*add your code here*/ +function dogYears(humanYears) { + return humanYears * 7; } +dogYears(10); +console.log(dogYears(10)); + /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 3 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ //Dog feeder - Depending on their weight and age, we need to know how many pounds of food to feed our dog each day! From 58f2dce57e33884c87c5744b34090b10118cf4d6 Mon Sep 17 00:00:00 2001 From: Rakan Abulathou Date: Mon, 24 Apr 2023 15:51:56 -0400 Subject: [PATCH 3/4] this is a test commit --- index.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 6f12c5d7e..709ad90b8 100644 --- a/index.js +++ b/index.js @@ -103,7 +103,7 @@ Adult Dogs 1 year and older up to 5 lbs - 5% of their body weight 6 - 10 lbs - 4% of their body weight 11 - 15 lbs - 3% of their body weight - > 15lbs - 2% of their body weight + > 15 lbs - 2% of their body weight Puppies less than 1 year 2 - 4 months 10% of their body weight @@ -131,9 +131,12 @@ NOTE 2: This is a great time to check the tests to see what it expects, versus w 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*/) { - /*add your code here*/ +function hungryDog(age, dogWeight) { + if ((age >= 1, weight <= 5)) { + let foodWeight = dogWeight / 0.05; + } } +hungryDog(); /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 4 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ From 767d0972b9c4d45d3da8d3cdd228ec995a4acf8f Mon Sep 17 00:00:00 2001 From: Rakan Abulathou Date: Tue, 25 Apr 2023 21:51:39 -0400 Subject: [PATCH 4/4] completed all tasks --- index.js | 73 +++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 57 insertions(+), 16 deletions(-) diff --git a/index.js b/index.js index 709ad90b8..3faa0a959 100644 --- a/index.js +++ b/index.js @@ -83,7 +83,7 @@ function dogYears(humanYears) { } dogYears(10); -console.log(dogYears(10)); +//console.log(dogYears(10)); /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 3 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ @@ -131,12 +131,26 @@ NOTE 2: This is a great time to check the tests to see what it expects, versus w 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(age, dogWeight) { - if ((age >= 1, weight <= 5)) { - let foodWeight = dogWeight / 0.05; +function hungryDog(weight, age) { + if (age >= 1) { + if (weight <= 5) { + return weight * 0.05; + } else if (weight <= 10) { + return weight * 0.04; + } else if (weight <= 15) { + return weight * 0.03; + } else if (weight > 15) return weight * 0.02; + } else if (age < 1) { + if (age >= 0.17 && age < 0.33) { + return weight * 0.1; + } else if (age >= 0.33 && age < 0.58) { + return weight * 0.05; + } else if (age >= 0.58 && age < 1) { + return weight * 0.04; + } } } -hungryDog(); +hungryDog(4, 1); /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 4 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ @@ -159,10 +173,20 @@ 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 */ +const randomNum = Math.random(); function game(user, computer) { - /*add your code here*/ + if (computer === user) { + return "it's a tie"; + } else if (computer === "rock" && user === "scissors") { + return "you lose!"; + } else if (computer === "paper" && user === "rock") { + return "you lose!"; + } else if (computer === "scissors" && user === "paper") { + return "you lose!"; + } else { + return "you win!"; + } } - /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 5 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ //Metric Converter @@ -174,9 +198,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(kilometers) { + return kilometers * 0.621371; } +miles(1); //Task 5b - Centimeters to Feet /* @@ -186,9 +211,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(cm) { + return cm / 30.48; } +feet(160); /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 6 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ @@ -203,9 +229,14 @@ Using the annoyingSong function below do the following: 3. Outside of the function, Make a loop that invokes annoying song with a number that decreases until it gets to 1 bottle left. 4. Each time the annoyingSong is run from this loop, it should console.log the string that was returned. */ - -function annoyingSong(/*add your code here*/) { - /*add your code here*/ +function annoyingSong(bottles) { + let string = `${bottles} bottles of soda on the wall, ${bottles} bottles of soda, take one down pass it around ${ + bottles - 1 + } bottles of soda on the wall`; + return string; +} +for (let i = 99; i > 1; i--) { + console.log(annoyingSong(i)); } /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 7 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ @@ -223,8 +254,18 @@ Using the grade function below do the following: below should return 'you got an F' */ -function grade(/*Your Code here */) { - /*Your Code here */ +function grade(percentage) { + if (percentage >= 90 && percentage <= 100) { + return "you got an A"; + } else if (percentage >= 80 && percentage <= 89) { + return "you got a B"; + } else if (percentage >= 70 && percentage <= 79) { + return "you got a C"; + } else if (percentage >= 60 && percentage <= 69) { + return "you got a D"; + } else if (percentage < 60) { + return "you got an F"; + } } /*💪💪💪💪💪💪💪💪💪💪 Stretch 💪💪💪💪💪💪💪💪💪💪*/