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
108 changes: 84 additions & 24 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,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,10 +74,11 @@ Do the following:
3. Return the newly calculated age
*/

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

function dogYears(age){ //invoking function and passing parameter age
return age * 7 //returning age times (dogyears)
}
console.log(dogYears(23))// console logging function w/ 23 as human age parameter



/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 3 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand Down Expand Up @@ -107,12 +108,34 @@ 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 conditional statement that clarifys that the dog is an adult. This allows us to proceed with the weight.
if (weight <= 5) { //if conditional statement that addresses weight.
return weight * .05;
}
else if (weight >= 6 && weight <= 10){
return weight * .04;
}
else if (weight >=11 && weight <=15){
return weight * .03;
}
else if (weight > 15) {
return weight * .02;
}
}
else if (age < 1){
if (age >= .16 && age <= .33){
return weight * .1;
}
else if (age >= .33 && age <= .583){
return weight * .05;
}
else if (age >= .583 && age <=1){
return weight * .04;
}
}
}



console.log(hungryDog(15,1));
/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 4 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/

// Rock, Paper, Scissors - Let's play against the computer!
Expand All @@ -133,11 +156,30 @@ Use the game function below to do the following:

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

let aiChoice = Math.round(Math.random() * 3);// aiChoice variable is limited to scope of block statement / Math.Round rounds number to nearest integer / Math.random:returns a random between 0 and 1 / multiply by 3 because there are 3 choices.
function aiOptions(){ //inovoking function that determines computer choice
if (aiChoice === 0){
return 'rock';
}
else if (aiChoice === 1){
return 'paper';
}
else {
return 'scissors';
}
}
function game(user, computer){
/*add your code here*/
if ((user === 'paper' && computer === 'rock') || (user === 'rock' && computer === 'scissors') || (user === 'scissors' && computer === 'paper')){
return 'you win!';
}
else if (user === computer){
return 'it\'s a tie';
}
else {
return 'you lose!';
}
}
console.log(game('scissors', aiOptions(aiChoice)));


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 5 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -151,9 +193,10 @@ 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;
}
console.log (miles(40))



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

console.log(feet(30))
;


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 6 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -181,9 +225,12 @@ 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 = num; 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`;
}
}
console.log(annoyingSong(10));


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 7 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -201,9 +248,22 @@ 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';
}
else if (score>=80 && score <= 89){
return 'you got a B';
}
else if (score >=70 && score <= 79){
return 'you got a C';
}
else if (score >=60 && score <= 69){
return 'you got a D';
}
else return 'you got an F';
}
console.log(grade(63));



Expand Down
Loading