From 3acc9f5f190a88e59c0cd436314d4378f7833151 Mon Sep 17 00:00:00 2001 From: FAZ KAY Date: Sat, 22 Aug 2020 01:32:39 -0700 Subject: [PATCH 1/3] task 1 is done --- index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 73f240372..d3aeb8faf 100644 --- a/index.js +++ b/index.js @@ -1,24 +1,33 @@ /************************************************************** Task 1: Warm-up! **************************************************************/ //Task a: declare a variable called votingAge, console log true if age > 18 (no function required) +var votingAge; +if (age>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) +var variable; -//Task c: Convert string ("1999") to integer (1999) (no function required) // hint look up the Number method +//Task c: Convert string ("1999") to integer (1999) (no function required) // hint look up the Number method +var convert = "1999"; +convert = 1999; //Task d: Write a function to multiply a*b +var a, b; +console.log(a*b); From df4da52a0b630ad08f66c7f3eac3a2e5d9e8cef3 Mon Sep 17 00:00:00 2001 From: FAZ KAY Date: Sat, 22 Aug 2020 23:24:40 -0700 Subject: [PATCH 2/3] half way done --- index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index d3aeb8faf..a258895cc 100644 --- a/index.js +++ b/index.js @@ -2,7 +2,7 @@ //Task a: declare a variable called votingAge, console log true if age > 18 (no function required) var votingAge; -if (age>18) { +if (votingAge>18) { console.log(true); } @@ -35,7 +35,8 @@ console.log(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 - +var humanAge; +console.log(humanAge*7); @@ -68,7 +69,11 @@ console.log(a*b); // 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 +var rock = 1; +var paper = 2; +var scissor = 3; +if ( Math.random()) From ec38cfa29d274ad247eb01740354b59291da438b Mon Sep 17 00:00:00 2001 From: FAZ KAY Date: Tue, 25 Aug 2020 21:06:05 -0700 Subject: [PATCH 3/3] mvp met --- index.js | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 116 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index a258895cc..21bf23914 100644 --- a/index.js +++ b/index.js @@ -1,31 +1,39 @@ /************************************************************** Task 1: Warm-up! **************************************************************/ + //Task a: declare a variable called votingAge, console log true if age > 18 (no function required) -var votingAge; +var votingAge = 19; 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 variable; - +var change = 23; //any number +var condition = 44; +if (condition !== change){ + change = condition; +} //Task c: Convert string ("1999") to integer (1999) (no function required) // hint look up the Number method var convert = "1999"; -convert = 1999; +console.log(Number(convert)); //Task d: Write a function to multiply a*b -var a, b; +var a=2; +var b=3; console.log(a*b); @@ -35,7 +43,7 @@ console.log(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 -var humanAge; +var humanAge =5; console.log(humanAge*7); @@ -58,7 +66,41 @@ console.log(humanAge*7); // 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 - + var weight = 5; + var age = 0.7; + var food; + + if (age >= 1) { + if (weight <= 5) { + food = weight*0.5; + console.log('You should feed: ' + food); + } + else if (weight <= 10) { + food = weight*0.4; + console.log('You should feed: ' + food); + } + else if (weight <= 15) { + food = weight*0.3; + console.log('You should feed: ' + food); + } + else{ + food = weight*0.2; + console.log('You should feed: ' + food); + } + } + else if (age <= 0.25) { + food = weight*0.1; + console.log('You should feed: ' + food); + } + else if (age <= 0.5) { + food = weight*0.05; + console.log('You should feed: ' + food); + } + else { + food = weight*0.04; + console.log('You should feed: ' + food); + } + @@ -69,25 +111,66 @@ console.log(humanAge*7); // 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 +var computer = 2; +var user = 3; var rock = 1; var paper = 2; var scissor = 3; -if ( Math.random()) +if ( Math.floor(Math.random()*3)+1); + +if(user === 1 && computer === 1){ + console.log('Tied'); +} +else if (user === 1 && computer === 2) { + console.log('Computer wins'); +} +else if (user === 1 && computer === 3) { + console.log('User wins'); +} +else if (user === 2 && computer === 1) { + console.log('User wins'); +} +else if (user === 2 && computer === 2) { + console.log('Tied'); +} +else if (user === 2 && computer === 3) { + console.log('Computer wins'); +} +else if (user === 3 && computer === 1) { + console.log('Computer wins'); +} +else if (user === 3 && computer === 2) { + console.log('User wins'); +} +else if (user === 3 && computer === 3) { + console.log('Tied'); +} + /************************************************************** Task 5 **************************************************************/ //Metric Converter //a. KM to Miles - should take the number of kilometers and convert it to the equal number of miles +var km; +var mi; +mi = km*0.621371; + +console.log(mi); //b. Feet to CM - should take the number of feet and convert it to the equal number of centimeters +var feet; +var cm; + +cm = feet*30.48; +console.log(cm); @@ -95,7 +178,14 @@ if ( Math.random()) // 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 soda = 99; + +for (let index = 0; index < 99; index++) { + // console.log( soda + ' numbers of soda on the wall' ); + console.log(`${soda} numbers of soda on the wall. `); + soda--; +} @@ -108,6 +198,23 @@ if ( Math.random()) //70s should be Cs //60s should be D //and anything below 60 should be F + +var mark = 80; +if (mark >= 90) { + console.log("Grade A"); +} +else if (mark >= 80 ) { + console.log("Grade B"); +} +else if (mark >= 70) { + console.log("Grade C"); +} +else if (mark >= 60) { + console.log("Grade D"); +} +else { + console.log("Grade F"); +}