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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Taylor Olson

# Introduction To JavaScript

The module challenge is the afternoon project or assignment that students work through independently. This expands on the guided project completed earlier with the instructor.
Expand All @@ -17,7 +19,7 @@ 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.

Expand Down
139 changes: 109 additions & 30 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ Do the following:
HINT: no function required
*/

const votingAge = 18

if (votingAge >= 18) {
console.log(true);
}
else {
console.log(false);
};

/*
Task 1b - Values
Expand All @@ -31,8 +38,15 @@ Do the following:
HINT: no function required
*/

let a = 4
let b = 7


if (b > a) {
console.log(a+1)
}
else {
console.log(a-1)
};


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

let birthYear = "1999";

console.log(Number(birthYear));


/*
Expand All @@ -58,10 +74,11 @@ 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);
};

multiply(6,2);


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 2 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -74,11 +91,11 @@ 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)
};

dogYears(3);

/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 3 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/

Expand Down Expand Up @@ -107,9 +124,23 @@ 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 (weight <= 5 && age >= 1) {
return (0.05*weight)
} else if (weight > 5 && weight <= 10) {
return (0.04*weight)
} else if (weight > 10 && weight <= 15) {
return (0.03*weight)
} else if (weight > 15) {
return (0.02*weight)
} else if (age < 1 && age >= 0.58333) {
return (0.04*weight)
} else if (age < 0.58333 && age >= 0.33333) {
return (0.05*weight)
} else if (age < 0.33333) {
return (0.10*weight)
}
};



Expand All @@ -125,18 +156,53 @@ HINT: While you can complete this with only conditionals based on strings, it ma
Use the game function below to do the following:
1. Receive 2 parameters the user's choice and the computer's choice
2. Return whether the user won, lost, or tied based on these rules of the game described below - the strings returned need to match the strings below exactly.
- win should return "you win!"
- lose should return "you lose!"
- tie should return "it's a tie"
- win should return "you win!"
- lose should return "you lose!"
- tie should return "it's a tie"

RULES OF THE GAME: Scissors beats Paper | Paper beats Rock | Rock beats Scissors | Or there's a tie

HINT: Remember that the order in which we pass in our arguments matters when it comes to parameters
*/

function game(user, computer){
/*add your code here*/

let computer = Math.random();

if (computer < 0.34) {
computer = "rock";
} else if (computer <= 0.67) {
computer = "paper";
} else {
computer = "scissors";
}

function game(user, computer) {
if (user===computer) {
return "it's a tie"
}
else if (user==="rock") {
if (computer==="scissors") {
return "you win!"
}
else if (computer==="paper") {
return "you lose!"
}
}
else if (user==="paper") {
if (computer==="scissors") {
return "you lose!"
} else if (computer==="rock") {
return "you win!"
}
}
else if (user==="scissors") {
if (computer==="rock") {
return "you lose!"
} else if (computer==="paper") {
return "you win!"
}
}
};



Expand All @@ -147,13 +213,13 @@ function game(user, computer){
/*
Using the miles function below do the following:
1. Receive a number of kilometers
2. Convert the number of kiolmeters received to miles
2. Convert the number of kiolmeters received to miles 0.6214*km=m
3. Return the number of miles
*/

function miles(/*add your code here*/){
/*add your code here*/
}
function miles(kilometers){
return(kilometers*0.621371)
};



Expand All @@ -165,10 +231,10 @@ 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)
};



/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 6 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -181,9 +247,10 @@ 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(number) {
for (i=number;number>=1;number--)
console.log(`${number} bottles of soda on the wall, ${number} bottles of soda, take one down pass it around ${number - 1} bottles of soda on the wall`);
};


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 7 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -201,11 +268,23 @@ 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(points){
if (points >= 90) {
return "you got an A"
}


else if (points >= 80 && points < 90) {
return "you got a B"
}
else if (points >= 70 && points < 80) {
return "you got a C"
}
else if (points >= 60 && points < 70) {
return "you got a D"
}
else if (points < 60) {
return "you got an F"
}
}

/*💪💪💪💪💪💪💪💪💪💪 Stretch 💪💪💪💪💪💪💪💪💪💪*/

Expand Down