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
110 changes: 79 additions & 31 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ Do the following:

HINT: no function required
*/

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


/*
Expand All @@ -30,8 +33,11 @@ Do the following:

HINT: no function required
*/


var car=2005
var wife=1
if(wife=1){
car=2004;
}



Expand All @@ -45,7 +51,8 @@ Do the following:

HINT: look up the Number method
*/

var year="1999"
Number(year)



Expand All @@ -57,11 +64,10 @@ Do the following:
2. Receive the numbers in the parameters: a and b
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(2,3)


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 2 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -74,10 +80,10 @@ Do the following:
3. Return the newly calculated age
*/

function dogYears(/*add your code here*/){
/*add your code here*/
function dogYears(a){
return a*7;
}

dogYears(3)


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 3 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -97,7 +103,7 @@ Use the hungryDog function and feeding requirements below to do the following:
up to 5 lbs - 5% of their body weight
6 - 10 lbs - 4% of their body weight
11 - 15 lbs - 3% of their body weight
> 15lbs - 2% of their body weight
> 15bs - 2% of their body weight

Puppies less than 1 year
2 - 4 months 10% of their body weight
Expand All @@ -107,11 +113,24 @@ 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 && weight<=5){
return weight*0.05;
}else if(age >=1 && weight>=6 && weight<=10){
return weight*0.04;
}else if(age>=1 && weight>=11 && weight<=15){
return weight*0.03;
}else if(age>=1 && weight>15){
return weight*0.02;
}else if(age>2/12 && age<=4/12){
return weight*0.1;
}else if(age>4/12 && age<=7/12){
return weight*.05;
}else if(age>7/12 && age<1){
return weight*.04;
}


}
hungryDog(15,1)

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

Expand All @@ -134,9 +153,21 @@ 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
*/

// 0:rock, 1:paper 2:scissors
let computer=Math.floor(Math.random()*3);
const rock=0;
const paper=1;
const scissors=2;
function game(user, computer){
/*add your code here*/
if(user===rock && computer===scissors || user===paper && computer===rock || user===scissors && computer===paper){
return "you win!";
}else if(user===rock && computer===paper || user===paper && computer===scissors || user===scissors && computer===rock){
return "you lose!";
}else if(user===computer){
return "it's a tie";
}
}
game(rock,computer)



Expand All @@ -151,10 +182,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;
}

miles(10)


//Task 5b - Feet to CM
Expand All @@ -165,10 +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){
return cm/30.48;
}

feet(160)


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 6 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -181,9 +212,26 @@ 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(a){
var currentBottles=a.toString();
var newBottles=(a-1).toString();
var stringOne=" bottles of soda on the wall, ";
var stringTwo=" bottles of soda, take one down pass it around ";
var stringThree=" bottles of soda on the wall";
// var outString=currentBottles.concat(stringOne,currentBottles,stringTwo,newBottles,stringThree)
var outString=currentBottles+stringOne+currentBottles+stringTwo+newBottles+stringThree;
return outString;
}
let number=5;
while(number>0){

// var numberTwo=number.toString();
console.log(annoyingSong(number))
number--;
if (number==0){
break;
}
}


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 7 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -202,15 +250,15 @@ Using the grade function below do the following:
*/

function grade(num){
if(num < 100 && num >= 90){
if(num<100 && num>=90){
return 'you got an A';
}else if(num <90 && num >= 80){
}else if(num<90 &&num>=80){
return 'you got a B';
}else if(num < 80 && num >= 70){
}else if(num<80 && num>=70){
return 'you got a C';
}else if(num < 70 && num >= 60){
}else if(num<70 && num>=60){
return 'you got a D';
}else if(num < 60){
}else if(num<60){
return 'you got an F';
}
}
Expand Down