From 4323537f5ddfcffb1da5efddbdf2f454a34bdc66 Mon Sep 17 00:00:00 2001 From: Zeth Date: Sun, 31 Jan 2021 18:47:34 -0800 Subject: [PATCH 1/7] First Commit questions 1/2 --- README.md | 13 +++++-------- index.js | 11 ++++++++++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index a4dde88f2..fbed57563 100644 --- a/README.md +++ b/README.md @@ -13,22 +13,20 @@ The module challenge is the afternoon project or assignment that students work t - write a basic for loop / while loop. - write control flow using if/else statements. - use function declarations, expressions, and arrow -functions and describe their differences - + functions and describe their differences + ## Introduction -Today you'll worth through 7 JavaScript Tasks to practice today's objectives and get familiar and comfortable with the foundations of JavaScript. +Today you'll work through 7 JavaScript Tasks to practice today's objectives and get familiar and comfortable with the foundations of JavaScript. Exercises are outlined in the `index.js` file, please read the instructions carefully for each task and complete it. Note that you may have to use your googling skills to research and look things up if you do not have all the information you need to complete the task. - ## Instructions ### Task 1: Set up Project Using VSCode and Command Line: - 1. Fork the repo 2. Clone your forked version of the repo 3. cd into your repo and create a branch with your first and last name @@ -38,7 +36,7 @@ Using VSCode and Command Line: ### Task 2: MVP -Find the `index.js` file and complete the tasks as written. +Find the `index.js` file and complete the tasks as written. As you work on your code you should make use of `console.log` to check your progress and debug. @@ -46,7 +44,7 @@ As you work on your code you should make use of `console.log` to check your prog After you have completed the requirements, try any of the following challenges. As always, note that these may require additional research beyond what you learned in this module. -- [ ] See tasks labelled stretch. Please ensure you've completed MVP before you attempt the stretch goals. Note that you may need to look forward to tomorrow's training kit in order to complete the task. +- [ ] See tasks labelled stretch. Please ensure you've completed MVP before you attempt the stretch goals. Note that you may need to look forward to tomorrow's training kit in order to complete the task. ## Submission format @@ -57,4 +55,3 @@ Please see Canvas for submission instructions specific to your cohort ## Resources 🧮 [Polya's 4 Step Approach to Problem Solving](http://web.mnstate.edu/peil/M110/Worksheet/PolyaProblemSolve.pdf) - diff --git a/index.js b/index.js index 29056f05f..8b77e2f4b 100644 --- a/index.js +++ b/index.js @@ -17,7 +17,8 @@ Do the following: HINT: no function required */ - +let votingAge = 18; +console.log(votingAge >= 18); /* @@ -31,8 +32,16 @@ Do the following: HINT: no function required */ +let varOne = 32; +let varTwo = 56; +if (varTwo > 50) { + varOne = 24; +} else { + varOne += 32; +} +console.log(varOne); /* From 75f190ff20da52f55e441322251cd80a51ebdb0b Mon Sep 17 00:00:00 2001 From: Zeth Date: Sun, 31 Jan 2021 19:12:46 -0800 Subject: [PATCH 2/7] dog years --- index.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 8b77e2f4b..ade6fa16e 100644 --- a/index.js +++ b/index.js @@ -55,7 +55,9 @@ Do the following: HINT: look up the Number method */ - +let year = '1999'; +year = Number(year); +console.log(year); /* @@ -67,8 +69,8 @@ Do the following: 3. Multiply a and b and return the answer */ -function multiply(/*add your code here*/){ - /*add your code here*/ +function multiply(a, b){ + return a * b; } @@ -83,8 +85,8 @@ Do the following: 3. Return the newly calculated age */ -function dogYears(/*add your code here*/){ - /*add your code here*/ +function dogYears(age){ + return age * 7; } From 19b174d49d6909972e600c268b395f1e1a08f0f5 Mon Sep 17 00:00:00 2001 From: Zeth Date: Sun, 31 Jan 2021 19:22:36 -0800 Subject: [PATCH 3/7] dog years --- index.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index ade6fa16e..b35455c66 100644 --- a/index.js +++ b/index.js @@ -118,12 +118,18 @@ Use the hungryDog function and feeding requirements below to do the following: NOTE: If done correctly, a weight of 15 lbs and age of 1 year would return 0.44999999999999996 */ -function hungryDog(/*add your code here*/){ - /*add your code here*/ +function hungryDog(weight, age){ + if (age >= 1) { + if (weight <= 5) return weight * 0.05; + if (weight <= 10) return weight * 0.04; + if (weight <= 15) return weight * 0.03; + else return weight * 0.02; + } + if (age/12 <= 4) return weight * 0.01; + if (age/12 <= 7) return weight * 0.05; + else return 0.04; } - - /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 4 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ // Rock, Paper, Scissors - Let's play against the computer! From 9ae53377e93111c42ad1f52849d436e918285903 Mon Sep 17 00:00:00 2001 From: Zeth Date: Sun, 31 Jan 2021 19:35:11 -0800 Subject: [PATCH 4/7] distance questions --- index.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index b35455c66..934238e0e 100644 --- a/index.js +++ b/index.js @@ -152,7 +152,9 @@ Use the game function below to do the following: */ function game(user, computer){ - /*add your code here*/ + if ( + (user === ) + ) } @@ -168,8 +170,8 @@ Using the miles function below do the following: 3. Return the number of miles */ -function miles(/*add your code here*/){ - /*add your code here*/ +function miles(km){ + return km * 0.621371; } @@ -182,8 +184,8 @@ Using the feet function below do the following: 3. Return number of feet */ -function feet(/*add your code here*/){ - /*add your code here*/ +function feet(cm){ + return cm / 30.48; } From 22e34112fc7b1b0be572d6ed1c0cf2c6def1bafd Mon Sep 17 00:00:00 2001 From: Zeth Date: Sun, 31 Jan 2021 19:59:56 -0800 Subject: [PATCH 5/7] rock,paper,scrissors --- index.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 934238e0e..d7303e6c1 100644 --- a/index.js +++ b/index.js @@ -152,9 +152,25 @@ Use the game function below to do the following: */ function game(user, computer){ - if ( - (user === ) - ) + if ( + (user === 'rock' && computer === 'rock') || + (user === 'paper' && computer === 'paper') || + (user === 'scissors' && computer === 'scissors') + ) { + return "it's a tie"; + } else if ( + (user === 'rock' && computer === 'paper') || + (user === 'paper' && computer === 'scissors') || + (user === 'scissors' && computer === 'rock') + ) { + return 'you lose!'; + } else if ( + (user === 'rock' && computer === 'scissors') || + (user === 'paper' && computer === 'rock') || + (user === 'scissors' && computer === 'paper') + ) { + return 'you win!'; + } } From 7c9cb8cc4997aaa83cf820603c02f645d30fbb09 Mon Sep 17 00:00:00 2001 From: Zeth Date: Sun, 31 Jan 2021 20:05:30 -0800 Subject: [PATCH 6/7] song --- index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index d7303e6c1..b8cddbf7a 100644 --- a/index.js +++ b/index.js @@ -172,6 +172,7 @@ function game(user, computer){ return 'you win!'; } } + @@ -216,10 +217,13 @@ Using the annoyingSong function below do the following: "{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(/*add your code here*/){ - /*add your code here*/ +function annoyingSong(num) { + for (let i = 1; i < num; i--) { + return `${num} bottles of soda on the wall, ${num} bottles of soda, take one down pass it around ${ + num - 1 + } bottles of soda on the wall`; } - +} /*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 7 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/ From 12a0aac8898cc69a24de5d4e75da71a9d594485f Mon Sep 17 00:00:00 2001 From: Zeth Date: Sun, 31 Jan 2021 20:07:09 -0800 Subject: [PATCH 7/7] grade --- index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index b8cddbf7a..5f19689c6 100644 --- a/index.js +++ b/index.js @@ -240,9 +240,13 @@ Using the grade function below do the following: below should return 'you got an F' */ -function grade(/*Your Code here */){ - /*Your Code here */ - } +function grade(score) { + if (score >= 90) return 'you got an A'; + if (score >= 80) return 'you got a B'; + if (score >= 70) return 'you got a C'; + if (score >= 60) return 'you got a D'; + return 'you got an F'; +}