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
103 changes: 77 additions & 26 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,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,9 +74,10 @@ 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
}
console.log(dogYears)



Expand Down Expand Up @@ -107,9 +108,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 ){ //older than 1
return(weight * .05);
}else if(weight === 6 || weight <= 10 && age >= 1){
return(weight * .04);
}else if(weight === 11 || weight <= 15 && age >= 1){
return(weight * .03);
}else if(weight >= 15 && age >= 1){
return(weight * .02); // younger than 1
}else if(age >= .2 || age <= .4){
return(age * .10);
}else if(age >=.4 || age <=.7){
return(age * .05);
}else if(age >= .7 || age <= 1){
return(age * .04);
}}
console.log(hungryDog(15,1));



Expand All @@ -126,12 +141,34 @@ 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*/
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "rock";
} else if(computerChoice <= 0.67) {
computerChoice = "paper";
} else {
computerChoice = "scissors";
}


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


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

Expand All @@ -140,13 +177,14 @@ function game(/*add your code here*/){
/*
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 kilometers received to miles
3. Return the number of miles
*/

function miles(/*add your code here*/){
/*add your code here*/
}
function miles(km, convertedMiles){
return km * 0.621371
}
console.log(5)



Expand All @@ -158,9 +196,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, convertedFeet){
return cm / 30.48
}
console.log(5)



Expand All @@ -174,10 +213,11 @@ 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(howManyBottles){
for (let i = howManyBottles; i > 0; 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 @@ -194,8 +234,19 @@ Using the grade function below do the following:
below 60 = F
*/

function grade(/*add your code here*/){
/*add your code here*/
function grade(score){
if(score >= 90 || score === 100){
return"you got an A";
}if(score >= 80 || score <=89){
return"you got a B";
}if(score >= 70 || score <= 79){
return"you got a C";
}if(score >= 60 || score <= 69){
return"you got a D";
}if(score < 60){
return"you got an F";
}
return(grade(85))
}


Expand Down Expand Up @@ -237,4 +288,4 @@ export default{
feet,
annoyingSong,
grade
}
}