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
182 changes: 162 additions & 20 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ Do the following:
HINT: no function required
*/


const votingAge = 18;
(votingAge > 17)

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

// let var1 = 1;
// let var2 = 2;

// if(var2 === 2) {
// var1 = 3;
// return var1;
// }



Expand All @@ -46,7 +54,8 @@ Do the following:
HINT: look up the Number method
*/


let year1 = '1999';
Number(year1);


/*
Expand All @@ -58,10 +67,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(5,4));


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

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

console.log(dogYears(5));



Expand Down Expand Up @@ -107,10 +120,32 @@ 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 < 6){
return weight * .05;
}
else if(age >= 1 && weight > 5 && weight < 11){
return weight * .04;
}
else if(age >= 1 && weight > 10 && weight < 16){
return weight * .03;
}
else if(age >= 1 && weight > 15){
return weight * .02;
}
else if(age >= .2 && age < .4){
return weight * .1;
}
else if(age >= .4 && age < .7){
return weight * .5;
}
else if(age >= .7 && age < 1){
return weight * .4;
}
}

console.log(hungryDog(15,1));



/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 4 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -132,11 +167,100 @@ 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()
*/

let computer = ' ';
let user = 'rock';
// Setting main variables

let computerChoice = Math.random();
//Generating a random number variable
console.log('computerChoice',computerChoice);


//Updating random variable with choice

function compConversion(computerChoice){
if(computerChoice < .34){
computer = 'rock';
}
else if(computerChoice > .33 && computerChoice < .67){
computer = 'paper';
}
else {computer = 'scissors';
}
}

compConversion(computerChoice);

console.log('compConversion', computer)

function game(user, computer){
/*add your code here*/
}



if(user === computer){
return "it's a tie";
}
else if(user === 'rock' && computer === 'scissors'){
return "you win!";
}
else if(user === 'paper' && computer === 'rock'){
return "you win!";
}
else if(user === 'scissors' && computer === 'paper'){
return "you win!";
}
else if(user === 'rock' && computer === 'paper'){
return "you lose!";
}
else if(user === 'paper' && computer === 'scissors'){
return "you lose!";
}
else if(user === 'scissors' && computer === 'rock'){
return "you lose!";
}
}

console.log('rps', game(user, computer));

//use functions to update the vars above

// let computer = Math.random();

// console.log('random number', computer)

// function game(user, computer){
// if(computer < .34){
// computer = 'rock';
// }
// else if(computer > .33 && computer < .67){
// computer = 'paper';
// }
// else {computer = 'scissors';
// }

// if(user === 'rock' && computer === 'scissors'){
// return "you win!";
// }
// else if(user === 'paper' && computer === 'rock'){
// return "you win!";
// }
// else if(user === 'scissors' && computer === 'paper'){
// return "you win!";
// }
// else if(user === 'rock' && computer === 'paper'){
// return "you lose!";
// }
// else if(user === 'paper' && computer === 'scissors'){
// return "you lose!";
// }
// else if(user === 'scissors' && computer === 'rock'){
// return "you lose!";
// }
// else if(user === computer){
// return "it's a tie";
// }
// }
// console.log('rps', game('rock', computer));


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

Expand All @@ -149,11 +273,11 @@ 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 * .621371;
}


console.log(miles(10));

//Task 5b - Feet to CM
/*
Expand All @@ -163,10 +287,11 @@ 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;
}

console.log(feet(1));


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 6 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -179,10 +304,14 @@ 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(soda){
for(let i = soda; i >= 0; i = i - 1)

return `${soda} bottles of soda on the wall, ${soda} bottles of soda, take one down pass it around ${soda - 1} bottles of soda on the wall`
}

console.log(annoyingSong(5));

/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 7 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/

Expand All @@ -199,10 +328,23 @@ 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 <= 100 && score > 89){
return 'you got a A';
}
else if(score <= 89 && score > 79){
return 'you got a B';
}
else if(score <= 79 && score > 69){
return 'you got a C';
}
else if(score <= 69 && score > 59){
return 'you got a D';
}
else return 'you got a F';
}

console.log('grading', grade(89));



Expand Down
Loading