Skip to content
Open
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
163 changes: 97 additions & 66 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ Do the following:

HINT: no function required
*/
var votingAge = "18";


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

/*
Task 1b - Values
Expand All @@ -31,10 +35,6 @@ Do the following:
HINT: no function required
*/





/*
Task 1c - Convert Strings to Numbers

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




/*
Task 1d - Multiply

Expand All @@ -58,11 +55,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;
}

console.log(multiply(5, 4));

/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 2 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/

Expand All @@ -74,11 +71,10 @@ 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;
}


console.log(dogYears(19));

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

Expand All @@ -105,13 +101,26 @@ Use the hungryDog function and feeding requirements below to do the following:
7 - 12 months 4% of their body weight

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(weightLbs, ageYears) {
if (ageYears >= 0.16 && ageYears <= 0.33) {
return weightLbs * 0.1;
} else if (ageYears >= 0.33 && ageYears <= 0.58) {
return weightLbs * 0.05;
} else if (ageYears >= 0.58 && ageYears < 1) {
return weightLbs * 0.04;
} else if (ageYears >= 1 && weightLbs <= 5) {
return weightLbs * 0.05;
} else if (ageYears >= 1 && weightLbs >= 6 && weightLbs <= 10) {
return weightLbs * 0.04;
} else if (ageYears >= 1 && weightLbs >= 11 && weightLbs <= 15) {
return weightLbs * 0.03;
} else if (ageYears >= 1 && weightLbs > 15) {
return weightLbs * 0.02;
}


}
console.log(hungryDog(15, 1));

/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 4 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/

Expand All @@ -127,28 +136,47 @@ Use the game function below to do the following:
HINT: While you can complete this with only conditionals based on strings, it may help to equate choice to a number when using Math.random()
*/

function game(/*add your code here*/){
/*add your code here*/
let computerMove = Math.random();
if (computerMove < 0.34) {
computerMove = "scissors";
} else if (computerMove <= 0.67) {
computerMove = "paper";
} else {
computerMove = "rock";
}

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



/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 5 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/

//Metric Converter
//Task 5a - KM to Miles
//Metric Converter
//Task 5a - KM to Miles
/*
Using the miles function below do the following:
1. Receive a number of kilometers
2. Convert the number of kiolmeters received to miles
3. Return the number of miles
*/

function miles(/*add your code here*/){
/*add your code here*/
}


function miles(kilometers) {
return kilometers * 0.621371;
}

//Task 5b - Feet to CM
/*
Expand All @@ -158,11 +186,9 @@ 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(centimeters) {
return centimeters / 30.48;
}

/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 6 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/

Expand All @@ -173,11 +199,13 @@ Using the annoyingSong function below do the following:
2. At each iteration, it should return this string:
"(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 (let i = number; i >= 1; i--) {
return `${i} bottles of soda on the wall, ${i} bottles of soda, take one down pass it around ${
i - 1
} bottles of soda on the wall`;
}

}

/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 7 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/

Expand All @@ -193,14 +221,20 @@ Using the grade function below do the following:
60-69 = D
below 60 = F
*/

function grade(/*add your code here*/){
/*add your code here*/

function grade(number) {
if (number >= 90) {
return "you got a A";
} else if (number >= 80 && number <= 89) {
return "you got a B";
} else if (number >= 70 && number <= 79) {
return "you got a C";
} else if (number >= 60 && number <= 69) {
return "you got a D";
} else if (number < 60) {
return "you got a F";
}




}

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

Expand All @@ -214,27 +248,24 @@ Using the vowelCounter function below do the following:
HINT - try looking up the .includes() method
*/


function vowelCounter(/*add your code here*/) {
/*add your code here*/
/*add your code here*/
}



/*🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑 Please do not modify anything below this line 🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑*/
function foo(){
console.log('its working');
return 'bar';
function foo() {
console.log("its working");
return "bar";
}
/*🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑 Don't touch the code after this line! 🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑*/
export default{
foo,
multiply,
dogYears,
hungryDog,
game,
miles,
feet,
annoyingSong,
grade
}
export default {
foo,
multiply,
dogYears,
hungryDog,
game,
miles,
feet,
annoyingSong,
grade,
};