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
4 changes: 2 additions & 2 deletions __tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('hungryDogFunction', ()=>{
});
describe('gameFunction', ()=>{
it('return win, lose or tie', ()=>{
expect(functions.game('rock', 'sissors')).toBe('you win!');
expect(functions.game('rock', 'scissors')).toBe('you win!');
})
it('return win, lose or tie', ()=>{
expect(functions.game('rock', 'paper')).toBe('you lose!');
Expand All @@ -46,7 +46,7 @@ describe('feetFunction', ()=>{
})
});
describe('annoyingSongFunction', ()=>{
it('a string that counts down based on the number imputted', ()=>{
it('a string that counts down based on the number inputted', ()=>{
expect(functions.annoyingSong(5)).toBe(`${5} bottles of soda on the wall, ${5} bottles of soda, take one down pass it around ${5 - 1} bottles of soda on the wall`);
})
});
Expand Down
125 changes: 98 additions & 27 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ Task 1a - Voting Age
Do the following:
1. Make a variable called votingAge and give it a value
2. Return true if age is 18 or higher

HINT: no function required
*/
let votingAge = 18;
if (votingAge => 18) {
console.log("Good to Vote")
} else {
console.log("Not Old Enough")
};



Expand All @@ -31,9 +36,9 @@ Do the following:
HINT: no function required
*/




var A = 'truth';
var B = (A == "false") ? "yes":"no";
console.log(B);

/*
Task 1c - Convert Strings to Numbers
Expand All @@ -45,7 +50,9 @@ Do the following:

HINT: look up the Number method
*/

var num = 1999
num.toString();
console.log(num.toString());



Expand All @@ -58,9 +65,11 @@ 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;
}
console.log(multiply(20 * 5));




Expand All @@ -74,9 +83,10 @@ 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;
}
dogYears(2);



Expand Down Expand Up @@ -107,8 +117,22 @@ 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(dogWeight, dogAge) {
if(dogWeight <= 5 && dogAge >= 1) {
return dogWeight * .05;
} else if((dogWeight >= 6 && dogWeight <= 10) && dogAge >= 1){
return dogWeight * .04;
} else if ((dogWeight >= 11 && dogWeight <= 15) && dogAge >= 1){
return dogWeight * .03;
} else if (dogWeight > 15 && dogAge >= 1){
return dogWeight * .02;
} else if (dogAge >= .2 && dogAge <= .4){
return dogWeight * .10;
} else if (dogAge >= .4 && dogAge <= .7){
return dogWeight * .05;
} else if (dogAge >= .7 && dogAge <= 1){
return dogWeight * .04
}
}


Expand All @@ -127,11 +151,43 @@ 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(userChoice, computerChoice){

if(userChoice=="rock")
userChoice=1;
else if(userChoice=="paper")
userChoice=2;
else if(userChoice=="scissors")
userChoice=3;

if(computerChoice=="rock")
computerChoice=1;
else if(computerChoice=="paper")
computerChoice=2;
else if(computerChoice=="scissors")
computerChoice=3;

if(userChoice===computerChoice){
(console.log(userChoice+" + "+computerChoice))
return "it's a tie";
}
else if(userChoice===1 && computerChoice===2){
return "you lose!";
}
else if (userChoice===1 && computerChoice===3)
return "you win!";
else if(userChoice===2 && computerChoice===3){
return "you lose!";
}
else if (userChoice===2 && computerChoice===1)
return "you win!";
else if(userChoice===3 && computerChoice===1){
return "you lose!";
}
else if (userChoice===3 && computerChoice===2)
return "you win!";
}



/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 5 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/

Expand All @@ -140,13 +196,15 @@ function game(/*add your code here*/){
/*
Using the miles function below do the following:
1. Receive a number of kilometers
2. Convert the number of kiolmeters received to miles
2. Convert the number of kilometers received to miles
3. Return the number of miles
*/

function miles(/*add your code here*/){
/*add your code here*/
function miles(kiloMeter){
return kiloMeter * 0.621371;
}
miles(10);




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

function feet(/*add your code here*/){
/*add your code here*/
function feet(cm){
return cm / 30.48;
}



/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 6 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/

// Let's Sing 99 Bottles of Soda on the Wall!
Expand All @@ -174,9 +231,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(startingNumber){
while (startingNumber > 0) {
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`
startingNumber --;
}
}
annoyingSong(5);


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 7 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -194,8 +255,18 @@ Using the grade function below do the following:
below 60 = F
*/

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


Expand All @@ -215,8 +286,8 @@ Using the vowelCounter function below do the following:
*/


function vowelCounter(/*add your code here*/) {
/*add your code here*/
function vowelCounter(aWord) {

}


Expand Down
Loading