From badea4d547123e4d178567c635edd1c1af3d0509 Mon Sep 17 00:00:00 2001 From: Nathaniel Patterson Date: Fri, 24 Jul 2020 01:35:03 -0400 Subject: [PATCH 1/6] first commit --- index.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 73f240372..58a053749 100644 --- a/index.js +++ b/index.js @@ -1,10 +1,9 @@ /************************************************************** Task 1: Warm-up! **************************************************************/ //Task a: declare a variable called votingAge, console log true if age > 18 (no function required) - - - - - +let votingAge; +if (votingAge > 18) { + console.log(true) +} //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) From 630ecaa53c71233039aed2c38b2e2804f2292d62 Mon Sep 17 00:00:00 2001 From: Nathan Patterson Date: Fri, 24 Jul 2020 03:09:31 -0400 Subject: [PATCH 2/6] 1 --- index.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/index.js b/index.js index 58a053749..5e0585921 100644 --- a/index.js +++ b/index.js @@ -5,29 +5,29 @@ if (votingAge > 18) { console.log(true) } //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) +let var1 = 5; +let var2 = 10; - - - +if (var2 = 10) { + var1 = 9; +} //Task c: Convert string ("1999") to integer (1999) (no function required) // hint look up the Number method - - - - +let a = '1999'; +Number(a); //Task d: Write a function to multiply a*b - - - - +let multiplyFunc = function (a,b) { + return a*b +} /************************************************************** 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 - - +let dogAge = function (age) { + return age * 7 +} /************************************************************** Task 3 **************************************************************/ From 07e5025e96aac05e6708264c374f164ba95dc78e Mon Sep 17 00:00:00 2001 From: Nathan Patterson Date: Fri, 24 Jul 2020 03:48:54 -0400 Subject: [PATCH 3/6] 1 --- index.js | 47 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 5e0585921..5da266a97 100644 --- a/index.js +++ b/index.js @@ -48,8 +48,25 @@ let dogAge = function (age) { // 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 - - +let dogFeeder = function (weight,age) { + if (age < .17 && age > .082){ + return weight * .1 + }else if (age > .17 && age < .583) { + return weight * .05 + }else if (age > .583 && age < 1) { + return weight * .04 + }else if (age >= 1 && weight <= 5) { + return weight * .05 + }else if (age >= 1 && weight <= 10 && weight >= 6) { + return weight * .04 + }else if (age >= 1 && weight <= 15 && weight >= 11) { + return weight * .03 + }else if (age >= 1 && weight >= 15) { + return weight * .02 + } + } + + dogFeeder(15,1) /************************************************************** Task 4 **************************************************************/ @@ -65,14 +82,22 @@ let dogAge = function (age) { /************************************************************** Task 5 **************************************************************/ //Metric Converter //a. KM to Miles - should take the number of kilometers and convert it to the equal number of miles +let kmToMiles = function (km) { + return km * .621371 +} +kmToMiles(25) //b. Feet to CM - should take the number of feet and convert it to the equal number of centimeters +let feetToCM = function (foot) { + return foot * 30.48 +} +feetToCM(25) @@ -81,7 +106,9 @@ let dogAge = function (age) { // 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` - +for (let i= 99; i>=1; i--) { + console.log(""+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") + } @@ -94,7 +121,19 @@ let dogAge = function (age) { //60s should be D //and anything below 60 should be F - +let gradeCalculator = function(grade) { + if (grade >= 90){ + return "A" + }else if (grade >= 80){ + return "B" + }else if (grade >= 80){ + return "C" + }else if (grade >= 60){ + return "D" + }else if (grade < 60){ + return "F" + } + } From 95a8e41c109e05be5b41e83938560d8c0d1396fb Mon Sep 17 00:00:00 2001 From: Nathan Patterson Date: Fri, 24 Jul 2020 21:33:13 -0400 Subject: [PATCH 4/6] Rock paper scissors done both of them --- index.js | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 5da266a97..b68d730a6 100644 --- a/index.js +++ b/index.js @@ -76,7 +76,43 @@ let dogFeeder = function (weight,age) { // 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 - + //1 = rock, 2 = paper, 3 = scissors +var computerChoice = function () { + let choice = Math.random(); + if(choice < .34){ + return 1; + }else if (choice >= .34 && choice < .67){ + return 2; + }else{ + return 3; + } +} + +let comRPS = computerChoice(); + +var rpsGame = function(compC, playerC) { + if (compC == 1 && playerC ==1 ) { + console.log("Computer also chose rock it's a tie") + }else if (compC == 1 && playerC == 2) { + console.log("Computer chose rock you win") + }else if (compC == 1 && playerC == 3) { + console.log("Computer chose rock computer wins") + }else if (compC == 2 && playerC == 1) { + console.log("Computer chose paper computer wins") + }else if (compC == 2 && playerC == 2) { + console.log("Computer also chose paper its a tie") + }else if (compC == 2 && playerC == 3) { + console.log("Computer chose paper you win") + }else if (compC == 3 && playerC == 2) { + console.log("Computer chose scissors computer wins") + }else if (compC == 3 && playerC == 1) { + console.log("Computer chose scissors you win") + }else if (compC == 3 && playerC == 3) { + console.log("Computer also chose scissors its a tie") + } +} +// put 1 for rock 2 for paper or 3 for scissors +rpsGame(comRPS,2) /************************************************************** Task 5 **************************************************************/ @@ -150,7 +186,60 @@ let gradeCalculator = function(grade) { //Take Rock, Paper, Sissors further //update your rock papers sissors code below to take a prompt from a user using the window object +let playerChoice = prompt("Choose: Rock, Paper, or Scissors"); +let pc = playerChoice.toLowerCase(); +console.log(pc); + +var playerChoiceNumber = function(c) { + if (c == 'rock'){ + return 1; + }else if (c == 'paper'){ + return 2; + }else if (c == 'scissors') { + return 3; + }else { + console.log("Hmm appears you didnt choose a correct choice"); + } +} + +//1 = rock, 2 = paper, 3 = scissors +var computerChoice = function () { + let choice = Math.random(); + if(choice < .34){ + return 1; + }else if (choice >= .34 && choice < .67){ + return 2; + }else{ + return 3; + } +} +let playerC = 2; +let plaRPS = playerChoiceNumber(pc); +let comRPS = computerChoice(); + +var rpsGame = function(compC, playerC) { + if (compC == 1 && playerC ==1 ) { + console.log("Computer also chose rock it's a tie") + }else if (compC == 1 && playerC == 2) { + console.log("Computer chose rock you win") + }else if (compC == 1 && playerC == 3) { + console.log("Computer chose rock computer wins") + }else if (compC == 2 && playerC == 1) { + console.log("Computer chose paper computer wins") + }else if (compC == 2 && playerC == 2) { + console.log("Computer also chose paper its a tie") + }else if (compC == 2 && playerC == 3) { + console.log("Computer chose paper you win") + }else if (compC == 3 && playerC == 2) { + console.log("Computer chose scissors computer wins") + }else if (compC == 3 && playerC == 1) { + console.log("Computer chose scissors you win") + }else if (compC == 3 && playerC == 3) { + console.log("Computer also chose scissors its a tie") + } +} +rpsGame(comRPS,plaRPS) From fabc10c2efcc67ecae8a148cb624932e478042de Mon Sep 17 00:00:00 2001 From: Nathaniel Patterson Date: Tue, 11 Aug 2020 15:45:47 -0400 Subject: [PATCH 5/6] finished last stretch goal --- index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/index.js b/index.js index b68d730a6..d7298f5b8 100644 --- a/index.js +++ b/index.js @@ -178,7 +178,18 @@ let gradeCalculator = function(grade) { // Hint - you may need to study tomorrow's traning kit on arrays // try looking up the .includes() method +function vowCount(string){ + let arrToCount = string.split(''); + console.log(arrToCount) + let vowelTotal = 0; + for (i in arrToCount){ + if (arrToCount[i] === 'a' ||arrToCount[i] === 'e' ||arrToCount[i] === 'i' ||arrToCount[i] === 'o' ||arrToCount[i] === 'u' ||arrToCount[i] === 'y') + vowelTotal = vowelTotal + 1; + } + return vowelTotal +} +console.log(vowCount('is y a vowel the thing goes aeiou and sometimes y meh who knows')) From d87de42a184225bd3a829801d53dd08a5f759f5c Mon Sep 17 00:00:00 2001 From: Nathaniel Patterson Date: Tue, 11 Aug 2020 15:50:49 -0400 Subject: [PATCH 6/6] finished last stretch goal --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index d7298f5b8..ebdabf6be 100644 --- a/index.js +++ b/index.js @@ -179,7 +179,8 @@ let gradeCalculator = function(grade) { // try looking up the .includes() method function vowCount(string){ - let arrToCount = string.split(''); + let lowerString = string.toLowerCase(); + let arrToCount = lowerString.split(''); console.log(arrToCount) let vowelTotal = 0; for (i in arrToCount){ @@ -189,8 +190,7 @@ function vowCount(string){ return vowelTotal } -console.log(vowCount('is y a vowel the thing goes aeiou and sometimes y meh who knows')) - +console.log(vowCount('is y aaAAAAAAa vowel the thing goes aeiou and sometimes y meh who knows')) /************************************************************** Stretch **************************************************************/