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
125 changes: 100 additions & 25 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ Do the following:
*/


// let votingAge = 25;
// if (votingAge >= 18){
// console.log('true');
// return true;
// }





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

let variableOne = 2
let variableTwo = 6

if (variableTwo === 6){
variableOne = 3
}
else{
variableOne = 7
}





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


let string = '1999';
Number(string);


/*
Expand All @@ -58,10 +79,10 @@ 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,12 +95,15 @@ Do the following:
3. Return the newly calculated age
*/

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

function dogYears(humanYears){
return humanYears * 7
}





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

//Dog feeder - Depending on their weight and age, we need to know how many pounds of food to feed our dog each day!
Expand Down Expand Up @@ -107,9 +131,25 @@ 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(pounds, years){
if (years >= 1 && pounds <= 5) {
return pounds * 0.05;
} else if (pounds <= 10) {
return pounds * 0.04;
} else if (pounds <= 15) {
return pounds * 0.03;
} else if (pounds > 15) {
return pounds * 0.02;
}
if (years <= 4/12) {
return pounds * 0.10;
} else if (years <= 7/12) {
return pounds * 0.05;
} else if (years < 1) {
return pounds * 0.04;
}
}
console.log(hungryDog(10, 1));



Expand All @@ -127,10 +167,28 @@ 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*/
}
// function game(any){
// /*add your code here*/
// }

function rockPaperScissors(yourMove) {
var computerMove = Math.ceil(Math.random()*3);
if(computerMove === 1) {
computerMove = rock;
} else if(computerMove === 2) {
computerMove = paper;
} else {
computerMove = scissors;
}
if(yourMove === computerMove){
return "tie";
} else if((yourMove === rock) && (computerMove === scissors) || ((yourMove === paper) && (computerMove === rock)) || ((yourMove === scissors) && (computerMove === paper))) {
return "win";
} else {
return "lose";
}
}



/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 5 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -143,9 +201,10 @@ Using the miles function below do the following:
2. Convert the number of kiolmeters received to miles
3. Return the number of miles
*/
//1 km = 0.6214 miles

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


Expand All @@ -158,8 +217,10 @@ Using the feet function below do the following:
3. Return number of feet
*/

function feet(/*add your code here*/){
/*add your code here*/
//1 ft = 30.48 cm

function feet(centimeters){
return centimeters / 30.48;
}


Expand All @@ -174,9 +235,9 @@ 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(/*add your code here*/){
// /*add your code here*/
// }


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 7 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -193,11 +254,25 @@ Using the grade function below do the following:
60-69 = D
below 60 = F
*/

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



let test = 92;
function grade(score){
if (score >= 90) {
return "you got an A";
} else if (score >= 80) {
return "you got a B";
} else if (score >= 70) {
return "you got a C";
} else if (score >= 60) {
return "you got a D";
} else {
return "you got an F";
}
}
console.log(grade(92));





Expand Down Expand Up @@ -232,9 +307,9 @@ export default{
multiply,
dogYears,
hungryDog,
game,
// game,
miles,
feet,
annoyingSong,
// annoyingSong,
grade
}