From 65333b984548a818a748f4583fac72ac920f0f4a Mon Sep 17 00:00:00 2001 From: Weijie XI Date: Tue, 11 Jun 2024 13:24:46 -0700 Subject: [PATCH 1/5] first update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5b384e4b0..8aef9499d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Introduction To JavaScript -The module challenge is the afternoon project or assignment that students work through independently. This expands on the guided project completed earlier with the instructor. +> The module challenge is the afternoon project or assignment that students work through independently. This expands on the guided project completed earlier with the instructor. ## Advanced CSS and JavaScript From e539b92d0642a91a5fc850fe36ae8d970e3e6972 Mon Sep 17 00:00:00 2001 From: Weijie XI Date: Fri, 14 Jun 2024 10:19:03 -0700 Subject: [PATCH 2/5] update content --- index.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index e2ebbd6a5..c1675b65c 100644 --- a/index.js +++ b/index.js @@ -20,7 +20,10 @@ Do the following: HINT: no function required */ - +const votingAge = 18; +if(votingAge >= 18){ + console.log(true); +} /* Task 1b - Values (not auto tested) @@ -34,9 +37,12 @@ Do the following: HINT: no function required */ - - - +let firstThing = 10; +let secondThing = 10; +if(firstThing === secondThing){ + firstThing = 30; +} +console.log(firstThing); /* Task 1c - Convert Strings to Numbers (not auto tested) @@ -49,6 +55,9 @@ Do the following: HINT: look up the Number method */ +const string = "1999"; +let number = Number(string); +console.log(number); @@ -77,8 +86,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; } From 688eb31ea9bf13be03c125ac07747a82fc99422d Mon Sep 17 00:00:00 2001 From: Weijie XI Date: Fri, 14 Jun 2024 11:01:52 -0700 Subject: [PATCH 3/5] update content --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index c1675b65c..edd029f87 100644 --- a/index.js +++ b/index.js @@ -48,7 +48,7 @@ console.log(firstThing); Task 1c - Convert Strings to Numbers (not auto tested) Do the following: - 1. Declare a variable with the string type value of "1999" + 1. Declare a variable with the string type value of "1999" 2. Convert the string value of "1999" to a integer value of 1999 3. Console log the result @@ -60,7 +60,6 @@ let number = Number(string); console.log(number); - /* Task 1d - Multiply @@ -73,7 +72,7 @@ Do the following: function multiply(num1, num2){ return num1 * num2; } - +console.log(multiply(2, 3)); /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 2 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ @@ -89,6 +88,7 @@ Do the following: function dogYears(age){ return age * 7; } +console.log(dogYears(15)); From 93f24ce54e25eb81ed9797fce484a35bab22cb0d Mon Sep 17 00:00:00 2001 From: Weijie XI Date: Fri, 14 Jun 2024 14:03:28 -0700 Subject: [PATCH 4/5] update content --- index.js | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index edd029f87..1e890d5c4 100644 --- a/index.js +++ b/index.js @@ -38,7 +38,7 @@ Do the following: */ let firstThing = 10; -let secondThing = 10; +let secondThing = 20; if(firstThing === secondThing){ firstThing = 30; } @@ -75,6 +75,7 @@ function multiply(num1, num2){ console.log(multiply(2, 3)); + /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 2 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ //Age in Dog years @@ -138,10 +139,32 @@ 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(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{ + return weight * 0.02; + } + }else{ + if(age <= 0.33){ + return weight * 0.1; + }else if(age <= 0.58){ + return weight * 0.05; + }else{ + return weight * 0.04; + } + } + + } +console.log(hungryDog(25, 3)); + /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 4 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ From 45a6e34ada4c3445c6e396bdcfb34d5d6906f4e8 Mon Sep 17 00:00:00 2001 From: Weijie XI Date: Fri, 14 Jun 2024 16:59:02 -0700 Subject: [PATCH 5/5] update content --- index.js | 55 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/index.js b/index.js index 1e890d5c4..d6a937682 100644 --- a/index.js +++ b/index.js @@ -151,6 +151,7 @@ function hungryDog(weight,age){ return weight * 0.02; } }else{ + console.log("age less one") if(age <= 0.33){ return weight * 0.1; }else if(age <= 0.58){ @@ -159,8 +160,6 @@ function hungryDog(weight,age){ return weight * 0.04; } } - - } console.log(hungryDog(25, 3)); @@ -189,9 +188,20 @@ RULES OF THE GAME: Scissors beats Paper | Paper beats Rock | Rock beats Scissors */ function game(user, computer){ - /*add your code here*/ -} + if(user === computer){ + return "it's a tie"; + }else if(user === "rock" && computer === "scissors"){ + return "you win!"; + }else if(user === "scissors" && computer === "paper"){ + return "you win!"; + }else if(user === "paper" && computer === "rock"){ + return "you win!"; + }else{ + return "you lose!"; + } +} +console.log(game("rock","paper")) /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 5 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ @@ -205,11 +215,12 @@ 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 ){ + const miles = kilometers * 0.621371; + return miles; } - +console.log(miles(100)); //Task 5b - Centimeters to Feet /* @@ -219,10 +230,11 @@ 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) { + const feet = cm / 30.48; + return feet; } - + console.log(feet(10)); /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 6 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ @@ -239,10 +251,12 @@ 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(number){ + + return `${number} bottles of soda on the wall, ${number} bottles of soda, take one down pass it around ${number-1} bottles of soda on the wall` +} +console.log(annoyingSong()); /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 7 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ @@ -259,8 +273,19 @@ 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(score){ + if(score >= 90){ + return "you got an A"; + }else if(score >=80){ + return "you got a B"; + }else if(score >=70){ + return "you got a C"; + }else if(score >=60){ + return "you got a D"; + }else{ + return "you got an F"; + + } }