From 781625265d91b03301c97e07dbbf84abc61b4577 Mon Sep 17 00:00:00 2001 From: Texi Schaeffer Date: Mon, 29 Aug 2022 18:37:20 -0500 Subject: [PATCH 1/6] completed task 1 --- index.js | 26 +++++++++++++++++++------- package-lock.json | 4 ++-- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index 9afb1fbac..8d6942a49 100644 --- a/index.js +++ b/index.js @@ -20,7 +20,12 @@ Do the following: HINT: no function required */ - +const votingAge = 18; +if(votingAge >= 18){ + console.log(true); +}else{ + console.log(false); +} /* Task 1b - Values (not auto tested) @@ -34,8 +39,15 @@ Do the following: HINT: no function required */ +let cat = 'Stevie'; +let smell = 'Stinky'; - +if(smell === 'Stinky'){ + cat = 'Piper'; +}else{ + cat = 'Stevie'; +} +console.log(cat); /* @@ -49,8 +61,8 @@ Do the following: HINT: look up the Number method */ - - +const year = '1999'; +console.log(Number(year)); /* Task 1d - Multiply @@ -61,10 +73,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 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ diff --git a/package-lock.json b/package-lock.json index f307c2d82..54abee067 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "codegraded-project-js", - "version": "0.0.8", + "version": "0.0.9", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "codegraded-project-js", - "version": "0.0.8", + "version": "0.0.9", "devDependencies": { "@babel/core": "^7.17.5", "@babel/plugin-transform-runtime": "^7.17.0", From ee9c7f60da62b579e91b0ac8ba6a9cbe0d9ede3c Mon Sep 17 00:00:00 2001 From: Texi Schaeffer Date: Mon, 29 Aug 2022 18:39:38 -0500 Subject: [PATCH 2/6] completed task 4 --- index.js | 50 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 8d6942a49..957ae9e86 100644 --- a/index.js +++ b/index.js @@ -89,10 +89,10 @@ 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; } - +console.log(dogYears(7)); /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 3 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ @@ -141,10 +141,24 @@ 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, weight){ + if(age >= 1 && weight <= 5){ + return weight * 0.05; + }else if(age >= 1 && weight > 5 && weight <= 10){ + return weight * 0.04; + }else if(age >= 1 && weight > 10 && weight <= 15){ + return weight * 0.03; + }else if(age >= 1 && weight > 15){ + return weight * 0.02; + }else if(age <=1 && age > 0.583){ + return weight * 0.04; + }else if(age <= 0.583 && age > 0.333){ + return weight * 0.05; + }else if(age < 0.333){ + return weight * 0.1 + } } - +console.log(hungryDog(1, 4)); /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 4 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ @@ -168,10 +182,32 @@ 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 computer = Math.random(); +if(computer <= 0.34){ + computer = 'rock'; +}else if(computer <= 0.67){ + computer = 'paper'; +}else if(computer > 0.67){ + computer = 'scissors'; +} + + function game(user, computer){ - /*add your code here*/ + if(user === computer){ + return 'it is 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('paper', computer)); + /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 5 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ From 34bfdfc394ed0d21754b81d21622223a9ea434ff Mon Sep 17 00:00:00 2001 From: Texi Schaeffer Date: Mon, 29 Aug 2022 18:42:31 -0500 Subject: [PATCH 3/6] completed mvp --- index.js | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index 957ae9e86..537b44844 100644 --- a/index.js +++ b/index.js @@ -221,10 +221,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(km){ + return km * 0.62; } - +console.log(miles(200)); //Task 5b - Feet to CM @@ -235,11 +235,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){ + return cm * 0.0328; } - +console.log(feet(600)); /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 6 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ @@ -255,9 +255,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(bottles){ + for(let i = bottles; i > 0; i--){ + return `${i} bottles of soda on the wall, ${i} bottles of soda, take one down pass it around ${i-1} bottles of soda on the wall`; + } } +console.log(annoyingSong(3)); /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 7 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ @@ -275,10 +278,22 @@ 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'; + } } +console.log(grade(72)); + /*💪💪💪💪💪💪💪💪💪💪 Stretch 💪💪💪💪💪💪💪💪💪💪*/ From b734917037106928bfa4a9535d7e22e9a7bce9ca Mon Sep 17 00:00:00 2001 From: Texi Schaeffer Date: Mon, 29 Aug 2022 18:50:52 -0500 Subject: [PATCH 4/6] tidied up spelling errors --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 537b44844..2a578a765 100644 --- a/index.js +++ b/index.js @@ -194,7 +194,7 @@ if(computer <= 0.34){ function game(user, computer){ if(user === computer){ - return 'it is a tie'; + return `it's a tie`; }else if(user === 'rock' && computer === 'scissors'){ return 'you win!'; }else if(user === ' scissors' && computer === 'paper'){ @@ -222,7 +222,7 @@ Using the miles function below do the following: */ function miles(km){ - return km * 0.62; + return km * 0.621371; } console.log(miles(200)); @@ -236,7 +236,7 @@ Using the feet function below do the following: */ function feet(cm){ - return cm * 0.0328; + return cm / 30.48; } console.log(feet(600)); From 8fc4f7609ef1b8397a61db86a6bbe1181f941e82 Mon Sep 17 00:00:00 2001 From: Texi Schaeffer Date: Mon, 29 Aug 2022 18:53:16 -0500 Subject: [PATCH 5/6] fixed hungryDog function --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 2a578a765..0e33f82e9 100644 --- a/index.js +++ b/index.js @@ -141,7 +141,7 @@ 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, weight){ +function hungryDog(weight, age){ if(age >= 1 && weight <= 5){ return weight * 0.05; }else if(age >= 1 && weight > 5 && weight <= 10){ @@ -158,7 +158,7 @@ function hungryDog(age, weight){ return weight * 0.1 } } -console.log(hungryDog(1, 4)); +console.log(hungryDog(4, 1)); /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 4 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ From 0b167be84965fe20300dd1ef5fbd88f392ab0cee Mon Sep 17 00:00:00 2001 From: Texi Schaeffer Date: Mon, 29 Aug 2022 19:02:25 -0500 Subject: [PATCH 6/6] completed all errors --- index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 0e33f82e9..860198ccb 100644 --- a/index.js +++ b/index.js @@ -196,13 +196,13 @@ function game(user, computer){ 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!'; + return `you win!`; }else if(user === 'paper' && computer === 'rock'){ - return 'you win!'; + return `you win!`; + }else if(user === 'scissors' && computer === 'paper'){ + return `you win!`; }else{ - return 'you lose!'; + return `you lose!`; } }