From d8a9fa4005e6dd458a748fdbad724286e03651b8 Mon Sep 17 00:00:00 2001 From: Amanda Nelson Date: Fri, 21 Aug 2020 20:50:51 -0400 Subject: [PATCH 01/10] First Tast complete. --- index.js | 18 ++++++++++++------ workspace.code-workspace | 7 +++++++ 2 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 workspace.code-workspace diff --git a/index.js b/index.js index 73f240372..2fe0957e8 100644 --- a/index.js +++ b/index.js @@ -1,26 +1,32 @@ /************************************************************** Task 1: Warm-up! **************************************************************/ //Task a: declare a variable called votingAge, console log true if age > 18 (no function required) - +var votingAge = 18; +console.log(votingAge > 18); //Task b: declare a variable and then use a conditional to change the value of that variable based on the value assigned to a second variable (no function required) - +var num1 = 2; +var num2 = 3; +num1 = num1+num2; +console.log(num1) //Task c: Convert string ("1999") to integer (1999) (no function required) // hint look up the Number method - - +var string = "1999"; +var number = parseInt(string); +console.log(number); //Task d: Write a function to multiply a*b - - +funtion (a=3,b=4){ + return a*b; +}; /************************************************************** Task 2 **************************************************************/ diff --git a/workspace.code-workspace b/workspace.code-workspace new file mode 100644 index 000000000..c7223d8ef --- /dev/null +++ b/workspace.code-workspace @@ -0,0 +1,7 @@ +{ + "folders": [ + { + "path": "." + } + ] +} From 1a96de551763160037298735718e6d4b62154235 Mon Sep 17 00:00:00 2001 From: Amanda Nelson Date: Fri, 21 Aug 2020 21:06:31 -0400 Subject: [PATCH 02/10] tast #2 complete --- index.js | 88 +++++++++++++++++--------------------------------------- 1 file changed, 26 insertions(+), 62 deletions(-) diff --git a/index.js b/index.js index 2fe0957e8..94aed63e5 100644 --- a/index.js +++ b/index.js @@ -4,16 +4,12 @@ var votingAge = 18; console.log(votingAge > 18); - - //Task b: declare a variable and then use a conditional to change the value of that variable based on the value assigned to a second variable (no function required) - var num1 = 2; var num2 = 3; -num1 = num1+num2; -console.log(num1) - +num1 = num1 + num2; +console.log(num1); //Task c: Convert string ("1999") to integer (1999) (no function required) // hint look up the Number method @@ -21,104 +17,72 @@ var string = "1999"; var number = parseInt(string); console.log(number); +//Task d: Write a function to multiply a*b -//Task d: Write a function to multiply a*b - -funtion (a=3,b=4){ - return a*b; -}; - +function multiplyAB(a, b) { + return a * b; +} +console.log(multiplyAB(3, 4)); /************************************************************** Task 2 **************************************************************/ //Age in Dog years -//write a function that takes your age and returns it to you in dog years - they say that 1 human year is equal to seven dog years - - - +//write a function that takes your age and returns it to you in dog years - they say that 1 human year is equal to seven dog years +function dogYears(humanAge, dogAge) { + return (dogAge = humanAge * 7); +} +console.log(dogYears(28)); /************************************************************** Task 3 **************************************************************/ -//Dog feeder +//Dog feeder //takes weight in pounds and age in years (note if the dog is a puppy the age will be a decimal) and returns the number of pounds of raw food to feed in a day. //feeding requirements -// adult dogs at least 1 year +// adult dogs at least 1 year // 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 +// 6 - 10 lbs - 4% of their body weight +// 11 - 15 lbs - 3% of their body weight +// > 15lbs - 2% of their body weight // Puppies less than 1 year // 2 - 4 months 10% of their body weight -// 4 - 7 months 5% of their body weight +// 4 - 7 months 5% of their body weight // 7 - 12 months 4% of their body weight // when you are finished invoke your function with the weight of 15 lbs and the age of 1 year - if your calculations are correct your result should be 0.44999999999999996 - - - - /************************************************************** Task 4 **************************************************************/ // Rock, Paper, Sissors // Your function should take a string (either rock paper or sissors) // it should return you won or you lost based on the rules of the game (you may need to look up the rules if you have not played before) -// use math.random to determine the computers choice -// hint while you can complete this with only conditionals based on strings it may help to equate choice to a number - - - +// use math.random to determine the computers choice +// hint while you can complete this with only conditionals based on strings it may help to equate choice to a number /************************************************************** Task 5 **************************************************************/ //Metric Converter //a. KM to Miles - should take the number of kilometers and convert it to the equal number of miles - - - - //b. Feet to CM - should take the number of feet and convert it to the equal number of centimeters - - - - /************************************************************** Task 6 **************************************************************/ // 99 bottles of soda on the wall // create a function called annoyingSong // the function should take a starting number as an argument and count down - at each iteration it should log (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` - - - - /************************************************************** Task 7 **************************************************************/ //Grade Calculator -//write a javaScript program that takes a mark out of 100 and returns a corisponding letter grade -//90s should be A -//80s should be B -//70s should be Cs -//60s should be D +//write a javaScript program that takes a mark out of 100 and returns a corisponding letter grade +//90s should be A +//80s should be B +//70s should be Cs +//60s should be D //and anything below 60 should be F - - - - /************************************************************** Stretch **************************************************************/ //Create a function that counts the number of vowels within a string. It should handle both capitalized and uncapitalized vowels. -// Hint - you may need to study tomorrow's traning kit on arrays +// Hint - you may need to study tomorrow's traning kit on arrays // try looking up the .includes() method - - - - /************************************************************** Stretch **************************************************************/ //Take Rock, Paper, Sissors further //update your rock papers sissors code below to take a prompt from a user using the window object - - - - - From 53c7516a29aec32c7721f29c57416d92094c9e9c Mon Sep 17 00:00:00 2001 From: Amanda Nelson Date: Fri, 21 Aug 2020 22:54:15 -0400 Subject: [PATCH 03/10] task 3 completed. --- index.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/index.js b/index.js index 94aed63e5..3a352c5ed 100644 --- a/index.js +++ b/index.js @@ -51,6 +51,34 @@ console.log(dogYears(28)); // when you are finished invoke your function with the weight of 15 lbs and the age of 1 year - if your calculations are correct your result should be 0.44999999999999996 +function dogFood(dogAge, dogWeight) { + if (dogAge >= 1 && dogWeight <= 5) { + return dogWeight * 0.05 + " pounds of food per day"; + } else if (dogAge >= 1 && (dogWeight >= 6, dogWeight <= 10)) { + return dogWeight * 0.04 + " pounds of food per day"; + } else if (dogAge >= 1 && (dogWeight >= 11, dogWeight <= 15)) { + return dogWeight * 0.03 + " pounds of food per day"; + } else if (dogAge >= 1 && dogWeight > 15) { + return dogWeight * 0.02 + " pounds of food per day"; + } //puppies: 2-4 mo = 0.16-0.34 + // 4-7 mo = 0.34-0.59 + // 7-12 mo = 0.59-0.99 + //using max weight of 50lbs for the puppies. + else if (dogAge < 0.16 && dogWeight < 5) { + return "this doggo should still be on breast milk"; + } else if ((dogAge >= 0.16, dogAge < 0.34) && dogWeight < 50) { + return dogWeight * 0.1 + " pounds of food per day"; + } else if ((dogAge >= 0.34, dogAge < 0.59) && dogWeight < 50) { + return dogWeight * 0.05 + " pounds of food per day"; + } else if ((dogAge >= 0.59, dogAge < 1) && dogWeight < 50) { + return dogWeight * 0.04 + " pounds of food per day"; + } +} +//task: +console.log(dogFood(1, 15)); +//puppy example: +console.log(dogFood(0.5, 2)); + /************************************************************** Task 4 **************************************************************/ // Rock, Paper, Sissors // Your function should take a string (either rock paper or sissors) From 74b1c012b83380f3dca089056163e95e96c0c623 Mon Sep 17 00:00:00 2001 From: Amanda Nelson Date: Fri, 21 Aug 2020 23:48:44 -0400 Subject: [PATCH 04/10] Task 4 completed --- index.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/index.js b/index.js index 3a352c5ed..004d986c4 100644 --- a/index.js +++ b/index.js @@ -86,6 +86,41 @@ console.log(dogFood(0.5, 2)); // use math.random to determine the computers choice // hint while you can complete this with only conditionals based on strings it may help to equate choice to a number +const rock = 0; +const paper = 1; +const scissors = 2; + +function rpsGame(humanChoice) { + const compChoice = Math.floor(Math.random() * 3); + //Rock choices: + if (humanChoice === "rock" && compChoice === rock) { + console.log("It's a tie! ROCK vs ROCK"); + } else if (humanChoice === "rock" && compChoice === paper) { + console.log("You loose 😢. ROCK vs PAPER"); + } else if (humanChoice === "rock" && compChoice === scissors) { + console.log("You win 🙌! ROCK vs SCISSORS"); + } + //Paper choices: + else if (humanChoice === "paper" && compChoice === rock) { + console.log("You win 🙌! PAPER vs ROCK"); + } else if (humanChoice === "paper" && compChoice === paper) { + console.log("It's a tie! PAPER vs PAPER"); + } else if (humanChoice === "paper" && compChoice === scissors) { + console.log("You loose 😢. PAPER vs SCISSORS"); + } + //Scissors choices: + else if (humanChoice === "scissors" && compChoice === rock) { + console.log("You loose 😢. SCISSORS vs ROCK"); + } else if (humanChoice === "scissors" && compChoice === paper) { + console.log("You win 🙌! SCISSORS vs PAPER"); + } else if (humanChoice === "scissors" && compChoice === scissors) { + console.log("It's a tie! SCISSORS vs SCISSORS"); + } +} +console.log(rpsGame("paper")); +console.log(rpsGame("rock")); +console.log(rpsGame("scissors")); + /************************************************************** Task 5 **************************************************************/ //Metric Converter //a. KM to Miles - should take the number of kilometers and convert it to the equal number of miles From 7f22549050560d759be99a5dcff17fe9c5c48f67 Mon Sep 17 00:00:00 2001 From: Amanda Nelson Date: Fri, 21 Aug 2020 23:57:25 -0400 Subject: [PATCH 05/10] task 5 complete --- index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/index.js b/index.js index 004d986c4..e3df5689d 100644 --- a/index.js +++ b/index.js @@ -125,8 +125,18 @@ console.log(rpsGame("scissors")); //Metric Converter //a. KM to Miles - should take the number of kilometers and convert it to the equal number of miles +function kmToMi(km) { + return km * 0.621371 + " miles"; +} +console.log(kmToMi(10)); + //b. Feet to CM - should take the number of feet and convert it to the equal number of centimeters +function feetToCm(feet) { + return feet * 30.48 + "cm"; +} +console.log(feetToCm(4)); + /************************************************************** Task 6 **************************************************************/ // 99 bottles of soda on the wall // create a function called annoyingSong From 01b81e03c948cd8d88216060f82c9f4252f71d6f Mon Sep 17 00:00:00 2001 From: Amanda Nelson Date: Sat, 22 Aug 2020 00:57:21 -0400 Subject: [PATCH 06/10] task 7 complete --- index.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/index.js b/index.js index e3df5689d..a482bdd94 100644 --- a/index.js +++ b/index.js @@ -151,6 +151,21 @@ console.log(feetToCm(4)); //60s should be D //and anything below 60 should be F +function grade(percent) { + if (percent >= 90) { + console.log("A"); + } else if (percent >= 80 && percent < 90) { + console.log("B"); + } else if (percent >= 70 && percent < 80) { + console.log("C"); + } else if (percent >= 60 && percent < 70) { + console.log("D"); + } else if (percent >= 0 && percent < 60) { + console.log("F"); + } +} +console.log(grade(76)); + /************************************************************** Stretch **************************************************************/ //Create a function that counts the number of vowels within a string. It should handle both capitalized and uncapitalized vowels. // Hint - you may need to study tomorrow's traning kit on arrays From 84dbb8e98b2b31d6d9a08ac893d831c2a5e32118 Mon Sep 17 00:00:00 2001 From: Amanda Nelson Date: Sun, 23 Aug 2020 14:38:58 -0400 Subject: [PATCH 07/10] MVP complete to push --- index.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/index.js b/index.js index a482bdd94..6cff9c96b 100644 --- a/index.js +++ b/index.js @@ -141,6 +141,20 @@ console.log(feetToCm(4)); // 99 bottles of soda on the wall // create a function called annoyingSong // the function should take a starting number as an argument and count down - at each iteration it should log (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` +var bottles; +function annoyingSong(counter) { + for (counter = counter; counter >= 1; counter = counter - 1) + console.log(counter + " bottles of soda on the wall."); + if (counter < 99) { + console.log( + counter + + " bottles of soda on the wall. " + + counter + + " bottles of soda. Take one down, pass it around..." + ); + } +} +console.log(annoyingSong(20)); /************************************************************** Task 7 **************************************************************/ //Grade Calculator From 729efa28dd2eb7f93a1a8aab84cb9cedddcc7abd Mon Sep 17 00:00:00 2001 From: Amanda Nelson Date: Mon, 24 Aug 2020 13:40:48 -0400 Subject: [PATCH 08/10] added Sprint for Rock, Paper Scissors game --- index.html | 21 ++++++++++++++------- index.js | 18 +++++++++++++----- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/index.html b/index.html index d49e1b2a0..aa3c77a26 100644 --- a/index.html +++ b/index.html @@ -1,11 +1,18 @@ - - - + + + Document - - + + + +

Play Rock, Paper, Scissors

+

+ Click the button below, play your hand, and see if you win against the + computer! +

+ - - \ No newline at end of file + + diff --git a/index.js b/index.js index 6cff9c96b..8b0baaf47 100644 --- a/index.js +++ b/index.js @@ -90,11 +90,19 @@ const rock = 0; const paper = 1; const scissors = 2; -function rpsGame(humanChoice) { +function rpsGame() { + let humanChoice = prompt("Rock, Paper, or Scissors?"); + humanChoice = humanChoice.toLocaleLowerCase(); + humanChoice = humanChoice.trim(); const compChoice = Math.floor(Math.random() * 3); //Rock choices: if (humanChoice === "rock" && compChoice === rock) { - console.log("It's a tie! ROCK vs ROCK"); + let h1 = document.querySelector("h1"); + h1.innerHTML = "It's a TIE"; + let p = document.querySelector("p"); + p.innerHTML = "ROCK vs ROCK - Play again below."; + document.body.scrollTop = 0; + document.documentElement.scrollTop = 0; } else if (humanChoice === "rock" && compChoice === paper) { console.log("You loose 😢. ROCK vs PAPER"); } else if (humanChoice === "rock" && compChoice === scissors) { @@ -117,9 +125,8 @@ function rpsGame(humanChoice) { console.log("It's a tie! SCISSORS vs SCISSORS"); } } -console.log(rpsGame("paper")); -console.log(rpsGame("rock")); -console.log(rpsGame("scissors")); +let rpsButton = document.querySelector(".rpsButton"); +rpsButton.addEventListener("click", rpsGame); /************************************************************** Task 5 **************************************************************/ //Metric Converter @@ -188,3 +195,4 @@ console.log(grade(76)); /************************************************************** Stretch **************************************************************/ //Take Rock, Paper, Sissors further //update your rock papers sissors code below to take a prompt from a user using the window object +//***********ABOVE IN RPSGAME From e92a6ec4e9fcbf3640dae7e0a808ea30a4908998 Mon Sep 17 00:00:00 2001 From: Amanda Nelson Date: Mon, 24 Aug 2020 14:08:15 -0400 Subject: [PATCH 09/10] index.html and index.js updated for rock paper scissors game. --- index.html | 23 ++++++++++++++++++++++- index.js | 46 ++++++++++++++++++++++++++++++++++------------ 2 files changed, 56 insertions(+), 13 deletions(-) diff --git a/index.html b/index.html index aa3c77a26..eef4ba69f 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,28 @@ Document - +

Play Rock, Paper, Scissors

diff --git a/index.js b/index.js index 8b0baaf47..b39c5d431 100644 --- a/index.js +++ b/index.js @@ -98,31 +98,53 @@ function rpsGame() { //Rock choices: if (humanChoice === "rock" && compChoice === rock) { let h1 = document.querySelector("h1"); - h1.innerHTML = "It's a TIE"; + h1.innerHTML = "It's a TIE!"; let p = document.querySelector("p"); p.innerHTML = "ROCK vs ROCK - Play again below."; - document.body.scrollTop = 0; - document.documentElement.scrollTop = 0; } else if (humanChoice === "rock" && compChoice === paper) { - console.log("You loose 😢. ROCK vs PAPER"); + let h1 = document.querySelector("h1"); + h1.innerHTML = "You loose 😢"; + let p = document.querySelector("p"); + p.innerHTML = "ROCK vs PAPER - Play again below."; } else if (humanChoice === "rock" && compChoice === scissors) { - console.log("You win 🙌! ROCK vs SCISSORS"); + let h1 = document.querySelector("h1"); + h1.innerHTML = "You win 🙌!"; + let p = document.querySelector("p"); + p.innerHTML = "ROCK vs SCISSORS - Play again below."; } //Paper choices: else if (humanChoice === "paper" && compChoice === rock) { - console.log("You win 🙌! PAPER vs ROCK"); + let h1 = document.querySelector("h1"); + h1.innerHTML = "You win 🙌!"; + let p = document.querySelector("p"); + p.innerHTML = "PAPER vs ROCK - Play again below."; } else if (humanChoice === "paper" && compChoice === paper) { - console.log("It's a tie! PAPER vs PAPER"); + let h1 = document.querySelector("h1"); + h1.innerHTML = "It's a TIE!"; + let p = document.querySelector("p"); + p.innerHTML = "PAPER vs PAPER - Play again below."; } else if (humanChoice === "paper" && compChoice === scissors) { - console.log("You loose 😢. PAPER vs SCISSORS"); + let h1 = document.querySelector("h1"); + h1.innerHTML = "You loose 😢"; + let p = document.querySelector("p"); + p.innerHTML = "PAPER vs SCISSORS - Play again below."; } //Scissors choices: else if (humanChoice === "scissors" && compChoice === rock) { - console.log("You loose 😢. SCISSORS vs ROCK"); + let h1 = document.querySelector("h1"); + h1.innerHTML = "You loose 😢"; + let p = document.querySelector("p"); + p.innerHTML = "SCISSORS vs ROCK - Play again below."; } else if (humanChoice === "scissors" && compChoice === paper) { - console.log("You win 🙌! SCISSORS vs PAPER"); + let h1 = document.querySelector("h1"); + h1.innerHTML = "You win 🙌!"; + let p = document.querySelector("p"); + p.innerHTML = "SCISSORS vs PAPER - Play again below."; } else if (humanChoice === "scissors" && compChoice === scissors) { - console.log("It's a tie! SCISSORS vs SCISSORS"); + let h1 = document.querySelector("h1"); + h1.innerHTML = "It's a TIE!"; + let p = document.querySelector("p"); + p.innerHTML = "SCISSORS vs SCISSORS - Play again below."; } } let rpsButton = document.querySelector(".rpsButton"); @@ -161,7 +183,7 @@ function annoyingSong(counter) { ); } } -console.log(annoyingSong(20)); +console.log(annoyingSong(5)); /************************************************************** Task 7 **************************************************************/ //Grade Calculator From 77d7906d99a3fe53bef53d10a1a255d9eea4e146 Mon Sep 17 00:00:00 2001 From: Amanda Nelson Date: Tue, 25 Aug 2020 19:50:34 -0400 Subject: [PATCH 10/10] slight edits to task 1:b" --- index.js | 4 +++- workspace.code-workspace | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index b39c5d431..e500bbbc9 100644 --- a/index.js +++ b/index.js @@ -8,7 +8,9 @@ console.log(votingAge > 18); var num1 = 2; var num2 = 3; -num1 = num1 + num2; +if (num1 < num2) { + num1 += num2; +} console.log(num1); //Task c: Convert string ("1999") to integer (1999) (no function required) // hint look up the Number method diff --git a/workspace.code-workspace b/workspace.code-workspace index c7223d8ef..b32285e15 100644 --- a/workspace.code-workspace +++ b/workspace.code-workspace @@ -1,7 +1,7 @@ { "folders": [ { - "path": "." + "path": "..\\..\\..\\..\\Devandapaige-Personal\\rock-paper-scissors-lizard-spock" } ] }