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
71 changes: 59 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ Do the following:

HINT: no function required
*/

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


/*
Expand All @@ -32,7 +35,12 @@ Do the following:

HINT: no function required
*/

let num1 = 25;
let num2 = 18;
if (num2 > 10) {
num1 = 8;
console.log(num1);
}



Expand All @@ -47,7 +55,13 @@ Do the following:

HINT: look up the Number method
*/

let b;
let a = "1999";
function convertToInt(num) {
b = parseInt(a);
return b;
}
console.log(b);



Expand All @@ -60,8 +74,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 @@ -75,11 +89,12 @@ Do the following:
2. Use the received value to calculate the age in dog years (1 human year is equal to 7 dog years)
3. Return the newly calculated age
*/

function dogYears(/*add your code here*/){
/*add your code here*/
let humanYears;
function dogYears(dogYear){
humanYears = dogYear * 7;
return humanYears;
}

dogYears(5);


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 3 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand Down Expand Up @@ -108,9 +123,41 @@ Puppies less than 1 year

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*/
let foodAmount;
function hungryDog(age, weight){
if (age < 1) {
if (age > 7 / 12) {
foodAmount = weight * 0.04;
return foodAmount;
}
else if (age > 4 /12) {
foodAmount = weight * 0.05;
return foodAmount;
}
else {
foodAmount = weight * 0.1;
return foodAmount;
}
}
else {
if (weight > 15) {
foodAmount = weight * 0.02;
return foodAmount;
}
else if (weight >= 11 && weight < 15) {
foodAmount = weight * 0.03;
return foodAmount;
}
else if (weight >= 6 && weight < 11) {
foodAmount = weight * 0.04;
return foodAmount;
}
else if (weight < 5) {
foodAmount = weight * 0.05;
return foodAmount;
}
else {console.log("Please enter proper weight and age")}
}
}


Expand Down
Loading