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
107 changes: 84 additions & 23 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ Do the following:

HINT: no function required
*/

const votingAge = 18;
function vaCheck(votingAge){
if(votingAge >= 18){
return true;
}
}
vaCheck(votingAge);


/*
Expand All @@ -31,7 +37,11 @@ Do the following:
HINT: no function required
*/


let value1 = 2;
let value2 = 3;
if(5 > 2){
value1 = value1 + value2;
}



Expand All @@ -58,8 +68,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,8 +84,8 @@ Do the following:
3. Return the newly calculated age
*/

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


Expand Down Expand Up @@ -107,9 +117,27 @@ 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(weight <= 5){
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(weight >= 2 && weight <= 4){
return weight * .1;
} else if (weight >= 4 && weight <= 7){
return weight * .05;
} else if (weight >= 7 && weight <= 12){
return weight * .04;
}
}
}



Expand All @@ -126,9 +154,24 @@ 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*/
let randomNum = Math.random();
let cChoice;
if (randomNum <= .33){
cChoice = 'rock';
} else if(randomNum <= .66){
cChoice = 'paper';
} else{
cChoice = 'scissors';
}
function game(choice, cChoice){
if (choice === 'rock' && cChoice === 'scissors' || choice === 'scissors' && cChoice ==='paper' || choice ==='paper' && cChoice === 'rock'){
return "you win!";
}else if (choice =='rock' && cChoice === 'paper' || choice === 'paper' && cChoice === 'scissors' || choice === 'scissors' && cChoice === 'rock'){
return "you lose!";
}
else{
return "it's a tie";
}
}


Expand All @@ -144,8 +187,9 @@ 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(kilometers){
let MetricConverter = kilometers * 0.621371;
return MetricConverter;
}


Expand All @@ -158,8 +202,9 @@ 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(centimeters){
let fToCM = centimeters / 30.48;
return fToCM;
}


Expand All @@ -174,8 +219,10 @@ 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(startingNumber){
for(let i = 0; i < startingNumber; i++){
return `${startingNumber} ` + 'bottles of soda on the wall,' + ` ${startingNumber} ` + 'bottles of soda, take one down pass it around'+ ` ${startingNumber - 1} ` + 'bottles of soda on the wall';
}
}


Expand All @@ -194,9 +241,22 @@ Using the grade function below do the following:
below 60 = F
*/

function grade(/*add your code here*/){
/*add your code here*/
function grade(score){
let cvtGrade;
if(score >= 90 && score <= 100){
cvtGrade = 'A';
} else if(score >= 80 && score <= 89){
cvtGrade = 'B';
} else if(score >= 70 && score <= 79){
cvtGrade = 'C';
} else if(score >= 60 && score <= 69){
cvtGrade = 'D';
} else{
cvtGrade = 'F';
}
return `you got a ${cvtGrade}`
}




Expand All @@ -214,10 +274,11 @@ Using the vowelCounter function below do the following:
HINT - try looking up the .includes() method
*/


function vowelCounter(/*add your code here*/) {
/*add your code here*/
}
// const listOfVowels = ['a', 'e', 'i', 'o', 'u']
// function vowelCounter(Vowel) {
// Vowel = Vowel.length()
// return Vowel
// }



Expand Down