Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -38,15 +36,15 @@ 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.

### Task 3: Stretch Goals

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

Expand All @@ -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)

85 changes: 64 additions & 21 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ Do the following:

HINT: no function required
*/

let votingAge = 18;
console.log(votingAge >= 18);


/*
Expand All @@ -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);


/*
Expand All @@ -46,7 +55,9 @@ Do the following:
HINT: look up the Number method
*/


let year = '1999';
year = Number(year);
console.log(year);


/*
Expand All @@ -58,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;
}


Expand All @@ -74,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;
}


Expand Down Expand Up @@ -107,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!
Expand All @@ -135,8 +152,27 @@ Use the game function below to do the following:
*/

function game(user, computer){
/*add your code here*/
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!';
}
}




Expand All @@ -151,8 +187,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;
}


Expand All @@ -165,8 +201,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;
}


Expand All @@ -181,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 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/

Expand All @@ -201,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';
}



Expand Down