From 68614b82881253d328337993ba0f475e7ed10285 Mon Sep 17 00:00:00 2001 From: reesharper Date: Tue, 8 Sep 2020 16:46:09 -0400 Subject: [PATCH 1/5] pre-node installation changes. --- index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.js b/index.js index 73f240372..46a4cf5aa 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,9 @@ /************************************************************** Task 1: Warm-up! **************************************************************/ //Task a: declare a variable called votingAge, console log true if age > 18 (no function required) +const myName = "rees Harper" +console.log(myName) From 9ef3232c1d76f2e6f11e7e61ba010ad23480ef80 Mon Sep 17 00:00:00 2001 From: reesharper Date: Tue, 8 Sep 2020 18:18:58 -0400 Subject: [PATCH 2/5] completed task 1 and 2 --- .vscode/launch.json | 17 +++++++++++++++++ index.js | 39 +++++++++++++++++++++++++++++++++++---- 2 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..ac44c31fe --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,17 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Launch Program", + "skipFiles": [ + "/**" + ], + "program": "${workspaceFolder}\\index.js" + } + ] +} \ No newline at end of file diff --git a/index.js b/index.js index 46a4cf5aa..81ada8f6a 100644 --- a/index.js +++ b/index.js @@ -1,36 +1,66 @@ /************************************************************** Task 1: Warm-up! **************************************************************/ //Task a: declare a variable called votingAge, console log true if age > 18 (no function required) -const myName = "rees Harper" - -console.log(myName) +const votingAge = 20; +if(votingAge >= 18){ + console.log("true"); +} else { + console.log("false") +} //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 variable1 = 20 +var variable2 = 5 +if(variable1 = 20){ + console.log(variable1 + variable2) +} //Task c: Convert string ("1999") to integer (1999) (no function required) // hint look up the Number method +var value1 = "23" + +parseInt(value1); +console.log(value1) //Task d: Write a function to multiply a*b +const a = 2 +const b = 4 +function multiply(a, b) { + + const product = a * b; + return product +} +console.log(multiply(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 +const myAge = 20 +const dogAge = 7 + +function dogYears (myAge, dogAge) { + + const newAge = myAge * dogAge; + return newAge +} + +console.log(dogYears(myAge, dogAge)); /************************************************************** Task 3 **************************************************************/ @@ -50,7 +80,8 @@ console.log(myName) // 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 - + + From 203ac953596768a875757933d28d3638c43f6558 Mon Sep 17 00:00:00 2001 From: reesharper Date: Tue, 8 Sep 2020 20:52:51 -0400 Subject: [PATCH 3/5] finished all MVP tasks except for 3 and 4 --- index.js | 70 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 60 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index 81ada8f6a..807d8d97e 100644 --- a/index.js +++ b/index.js @@ -82,6 +82,30 @@ console.log(dogYears(myAge, dogAge)); // 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 dogFeeder (age, weight) { + + if(age >= 1 && weight <= 5) { + return weight * .05 + } + + /* if (this first condition is met) { + if (this second condition is also met) { + then run this code + } + else if (this condition is also met) { + run this code + } + + } + else if (another condition is met) { + if (this condition is also met) { + run this code + } else if (this condition is met) { + run this code + } + } */ + +} @@ -93,31 +117,45 @@ console.log(dogYears(myAge, dogAge)); // 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 +function kiloConverter (kilo) { + console.log (kilo * 0.621372); +} - +kiloConverter(5); //b. Feet to CM - should take the number of feet and convert it to the equal number of centimeters +function feetConverter (feet) { + console.log (feet * 30.48); +} - - +feetConverter(5); /************************************************************** 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` +function annoyingSong (startingNumber) { + var i = 0; + var bottles = startingNumber; + + while (i != startingNumber) { + console.log(bottles, "bottles of soda on the wall"); + i++; + bottles--; + } +} - - +annoyingSong(99) /************************************************************** Task 7 **************************************************************/ //Grade Calculator @@ -127,10 +165,22 @@ console.log(dogYears(myAge, dogAge)); //70s should be Cs //60s should be D //and anything below 60 should be F - - - +function gradeCalculator (grade) { + if (grade >= 90){ + console.log("A"); + } else if (grade >= 80 && grade < 89) { + console.log("B"); + } else if (grade >= 70 && grade < 79) { + console.log("C") + } else if (grade >= 60 && grade < 69) { + console.log("D") + } else { + console.log("F") + } +} + +gradeCalculator(76); /************************************************************** Stretch **************************************************************/ //Create a function that counts the number of vowels within a string. It should handle both capitalized and uncapitalized vowels. From 170a63645a476231044f1333edc63326aef6c4ad Mon Sep 17 00:00:00 2001 From: reesharper Date: Tue, 8 Sep 2020 21:38:42 -0400 Subject: [PATCH 4/5] finished task 4 only leaving task 3 remaining --- index.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/index.js b/index.js index 807d8d97e..9290e272f 100644 --- a/index.js +++ b/index.js @@ -117,8 +117,42 @@ function dogFeeder (age, weight) { // 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 +function computerChoice1() { + let computerSelection = (Math.floor(Math.random() * 3)); + if (computerSelection === 0) { + return "rock"; + } else if (computerSelection === 1) { + return "paper"; + } else if (computerSelection === 2) { + return "scissors"; + } + +} + + function game (userChoice) { + const computerChoice = computerChoice1(); + // console.log(computerChoice); + // console.log(userChoice); + if(userChoice === computerChoice) { + console.log ("Tie"); + } else if (userChoice === "rock" && computerChoice === "paper") { + console.log ("loss! paper beats rock"); + } else if (userChoice === "rock" && computerChoice === "scissors") { + console.log ("win! rock beats scissors"); + } else if (userChoice === "paper" && computerChoice === "rock") { + console.log ("win! paper beats rock"); + } else if (userChoice === "paper" && computerChoice === "scissors") { + console.log ("loss! scissors beat paper"); + } else if (userChoice === "scissors" && computerChoice === "rock") { + console.log ("loss! rock beats scissors"); + } else if (userChoice === "scissors" && computerChoice === "paper") { + console.log ("win! scissors beat paper"); + } + } + +game("paper"); /************************************************************** Task 5 **************************************************************/ //Metric Converter From c07d486f4aef4406229f2555306856407617ed8b Mon Sep 17 00:00:00 2001 From: reesharper Date: Tue, 8 Sep 2020 23:23:00 -0400 Subject: [PATCH 5/5] finished task 3 completing all the MVP tasks --- index.js | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/index.js b/index.js index 9290e272f..e66a2896a 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,7 @@ const votingAge = 20; if(votingAge >= 18){ console.log("true"); } else { - console.log("false") + console.log("false"); } @@ -49,14 +49,14 @@ console.log(multiply(a, b)); //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 -const myAge = 20 -const dogAge = 7 +const myAge = 20; +const dogAge = 7; function dogYears (myAge, dogAge) { const newAge = myAge * dogAge; - return newAge + return newAge; } @@ -85,29 +85,32 @@ console.log(dogYears(myAge, dogAge)); function dogFeeder (age, weight) { if(age >= 1 && weight <= 5) { - return weight * .05 - } - - /* if (this first condition is met) { - if (this second condition is also met) { - then run this code + return weight * .05; + } + else if (age >= 1){ + if (weight >= 6 && weight <= 10) { + return weight * .04; + } + else if (age >= 1) { + if (weight >= 11 && weight <= 15) { + return weight * .03; + } + else if (age >= 1 && weight >= 15) { + return weight * .02; + } } - else if (this condition is also met) { - run this code - } - } - else if (another condition is met) { - if (this condition is also met) { - run this code - } else if (this condition is met) { - run this code - } - } */ + if (age >= .2 && age < .4) { + return weight * .1; + } else if (age >= .4 && age < .7) { + return weight * .05; + } else if (age >= .7 && age < 1) { + return weight * .04; + } } - +console.log(dogFeeder(1,15)); /************************************************************** Task 4 **************************************************************/ @@ -189,7 +192,7 @@ function annoyingSong (startingNumber) { } } -annoyingSong(99) +annoyingSong(99); /************************************************************** Task 7 **************************************************************/ //Grade Calculator