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
120 changes: 101 additions & 19 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@ Do the following:

HINT: no function required
*/
const votingAge = 18;

if(votingAge>17){
true;
}
else{
false;
}

console.log(votingAge)

/*
Task 1b - Values
Expand All @@ -31,9 +39,13 @@ Do the following:
HINT: no function required
*/

let variable1 = "hairo"
let variable2 = "tania"
if(variable2 === "tania"){
variable1 = "joseph"
}



console.log(variable1)

/*
Task 1c - Convert Strings to Numbers
Expand All @@ -45,6 +57,14 @@ Do the following:

HINT: look up the Number method
*/
let str = "1999"

function toNumber (){
let newNumber = Number(str);
return newNumber;
}
console.log(toNumber());




Expand All @@ -58,10 +78,12 @@ Do the following:
3. Multiply a and b and return the answer
*/

function multiply(/*add your code here*/){
function multiply(a,b/*add your code here*/){
let result = a * b
return result;
/*add your code here*/
}

multiply(1,2)


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

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


dogYears(5)

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

Expand Down Expand Up @@ -107,11 +130,36 @@ 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*/){
function hungryDog(weight,age/*add your code here*/){
if(age >= 1){
if(weight <= 5){
weight * .05;
}
if(weight >= 6 || weight <= 10){
weight * .04;
}
if(weight >= 11 || weight <= 15){
return weight * .03;
}
else{weight * .02}

/*add your code here*/
}


if(age < 12/12){
if(age >= 1/12 && age <= 4/12){
return weight * .10;
}
if(age >= 5/12 && age <= 7/12){
return weight * .05;
}
if(age >= 8/12 && age <= 12/12){
return weight * .04;
}

}

console.log(weight);
}

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

Expand All @@ -127,9 +175,21 @@ 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(playerChoice,computerChoice/*add your code here*/){
computerChoice = Math.floor(Math.random() * 3)
if(playerChoice === "rock" && computerChoice === 0){
return "it's a tie";
}
else if(playerChoice === "paper" && computerChoice === 1){
return"you lose";
}
else{
return "you win";
}

}
console.log(game("rock"))




Expand All @@ -144,8 +204,10 @@ Using the miles function below do the following:
3. Return the number of miles
*/

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


Expand All @@ -158,9 +220,12 @@ Using the feet function below do the following:
3. Return number of feet
*/

function feet(/*add your code here*/){
function feet(cm/*add your code here*/){
/*add your code here*/
let feet = cm / 30.48;
return feet;
}
console.log(feet())



Expand All @@ -174,9 +239,13 @@ 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(bottlesN/*add your code here*/){
while(bottlesN >= 5) {
return `${bottlesN} bottles of soda on the wall, ${bottlesN} bottles of soda, take one down pass it around ${bottlesN - 1} bottles of soda on the wall`;
}
return annoyingSong();
}



/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 7 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -194,11 +263,24 @@ Using the grade function below do the following:
below 60 = F
*/

function grade(/*add your code here*/){
/*add your code here*/
function grade(score/*add your code here*/){
if( score >= 90){
return "A";
}


else if (score >= 80 && score < 90){
return "you got a B";
}
else if (score >= 70 && score < 80){
return "C";
}
else if (score >= 60 && score < 70){
return "D";
}
else {
return "F";
}
/*add your code here*/
}



Expand Down