From 94c7a935fb60350973004acb542c935b85000675 Mon Sep 17 00:00:00 2001 From: Brian Kubes Date: Tue, 11 Aug 2020 14:08:22 -0700 Subject: [PATCH 1/2] almost done --- index.js | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 103 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 73f240372..27216d982 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,9 @@ /************************************************************** Task 1: Warm-up! **************************************************************/ //Task a: declare a variable called votingAge, console log true if age > 18 (no function required) +// const votingAge = 18; +// if (age > votingAge){ +// console.log("true"); +// } @@ -7,18 +11,28 @@ //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 x = 5; +// let y = 3; +// if (y > 1){ +// x += y; +// console.log(x); +// } //Task c: Convert string ("1999") to integer (1999) (no function required) // hint look up the Number method +// Number("1999"); //Task d: Write a function to multiply a*b +// function mult(a,b){ +// return (a*b); +// } @@ -27,7 +41,9 @@ //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 - +// function dogYears(age){ +// console.log(age*7); +// } @@ -48,7 +64,31 @@ // 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 - + +// function dogFeeder(weight, years){ +// if (years >= 1){ +// if (weight <= 5){ +// return (weight*.05); +// } else if (weight >= 6 && weight <= 10){ +// return (weight*.04); +// }else if (weight >= 11 && weight <= 15){ +// console.log(weight*.03); +// }else if (weight > 15){ +// return (weight*.02); +// } + +// }else if (years >= (2/12) && years <= (4/12)){ +// return (weight*.1); +// }else if (years >= (4/12) && years <= (7/12)){ +// return (weight*.05); +// }else if (years >= (7/12) && years < 1){ +// return (weight*.04); +// } + +// } + +// dogFeeder(15,1) + @@ -60,6 +100,37 @@ // 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 playRPS(choice){ +// if (choice === "rock"){ +// gameOn(1); +// }else if (choice === "paper"){ +// gameOn(2); +// }else{ +// gameOn(3); +// } + +// function gameOn(me){ +// let opponent = Math.floor((Math.random()*3)+1); +// if (opponent === me){ +// console.log("tie"); +// } else if (opponent === 1 && me === 2){ +// console.log("You won!"); +// } else if (opponent === 1 && me === 3){ +// console.log("You lost"); +// } else if (opponent === 2 && me === 1){ +// console.log("You lost"); +// } else if (opponent === 2 && me === 3){ +// console.log("You won"); +// } else if (opponent === 3 && me === 1){ +// console.log("You won!"); +// } else if (opponent === 3 && me === 2){ +// console.log("You lost"); +// } +// } +// } + +// playRPS("rock"); + @@ -67,14 +138,19 @@ //Metric Converter //a. KM to Miles - should take the number of kilometers and convert it to the equal number of miles +// function kmToMiles(km){ +// console.log(km*0.621371); +// } +// kmToMiles(10); //b. Feet to CM - should take the number of feet and convert it to the equal number of centimeters +// const feetToCm =(feet) => console.log(feet*30.48); - +// feetToCm(15); /************************************************************** Task 6 **************************************************************/ @@ -82,7 +158,14 @@ // 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(number){ +// while (number > 0){ +// number -= 1; +// console.log(number); +// } +// } +// annoyingSong(5); @@ -95,7 +178,23 @@ //60s should be D //and anything below 60 should be F - +// function gradeCalc(){ +// const num = Math.round(Math.random()*100) +// console.log(num) +// if (num >= 90){ +// console.log("A"); +// } else if (num >= 80 && num < 90){ +// console.log("B"); +// }else if (num >= 70 && num < 80){ +// console.log("C"); +// } else if (num >= 60 && num < 70){ +// console.log("D"); +// } else if (num < 60){ +// console.log("F"); +// } +// } + +// gradeCalc(); From 754f092e81e0b64a04052860e7e2a053263cf974 Mon Sep 17 00:00:00 2001 From: Brian Kubes Date: Tue, 11 Aug 2020 15:06:43 -0700 Subject: [PATCH 2/2] Finished --- index.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/index.js b/index.js index 27216d982..02e59f1e2 100644 --- a/index.js +++ b/index.js @@ -203,6 +203,27 @@ // Hint - you may need to study tomorrow's traning kit on arrays // try looking up the .includes() method +// function vowelCounter(myString){ +// const myStringLower = myString.toLowerCase() +// let count = 0; + +// for (let i = 0; i < myStringLower.length; i++){ +// if (myStringLower[i].includes('a')){ +// count += 1; +// }else if (myStringLower[i].includes('e')){ +// count += 1; +// }else if (myStringLower[i].includes('i')){ +// count += 1; +// }else if (myStringLower[i].includes('o')){ +// count += 1; +// }else if (myStringLower[i].includes('u')){ +// count += 1; +// } +// }console.log(count); +// } + +// vowelCounter("hello") +