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

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


if(votingAge >= 18){
console.log(true);
}else{
console.log(false);
}

/*
Task 1b - Values
Expand All @@ -32,9 +37,16 @@ Do the following:

HINT: no function required
*/
let dog = 'Ada';
let behavior = 'bad';

if(behavior === 'bad'){
dog = 'Noa';
}else{
dog = 'Ada';
}


console.log(dog);


/*
Expand All @@ -47,8 +59,8 @@ Do the following:

HINT: look up the Number method
*/


const party = '1999';
console.log(Number(party));


/*
Expand All @@ -60,10 +72,12 @@ 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, c){
return a * c
}

console.log(multiply(3, 3));



/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 2 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -76,10 +90,11 @@ 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
}

console.log(dogYears(5))


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 3 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand Down Expand Up @@ -109,9 +124,26 @@ 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*/
function hungryDog(weight, age){
if(age >= 1 && weight <= 5){
return weight * 0.05;
}else if(age >= 1 && weight >= 6 && weight <= 10){
return weight * 0.04;
}else if(age >= 1 && weight >= 11 && weight <= 15){
return weight * 0.03;
}else if(age >= 1 && weight > 15){
return weight * 0.02;
}else if(age > 0.1666 && age <= 0.333){
return weight * 0.1;
}else if(age <= 0.333 && age <= 0.583){
return weight * 0.05;
}else if(age <= 0.583 && age <= 0.99){
return weight * 0.04;
}else{
return 'please try again';
}
}
console.log(hungryDog(15, 1));



Expand All @@ -138,10 +170,42 @@ RULES OF THE GAME: Scissors beats Paper | Paper beats Rock | Rock beats Scissors
HINT: Remember that the order in which we pass in our arguments matters when it comes to parameters
*/

function game(user, computer){
/*add your code here*/
let computer = Math.random();

if(computer <= 0.34){
computer = 'rock';
}else if(computer <= 0.67){
computer = 'paper';
}else if(computer > 0.67){
computer = 'scissors';
}

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

console.log(game('paper', computer));



/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 5 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -155,10 +219,12 @@ 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 * 0.621371
}

console.log(miles(2));



//Task 5b - Feet to CM
Expand All @@ -169,9 +235,10 @@ 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 (3));



Expand All @@ -185,9 +252,13 @@ Using the annoyingSong function below do the following:
"{number you gave as an argument} bottles of soda on the wall, {number you gave as an argument} bottles of soda, take one down pass it around {number you gave as an argument minus 1} bottles of soda on the wall"
*/

function annoyingSong(/*add your code here*/){
/*add your code here*/
function annoyingSong(number){
for (let i = number; i > 0; i --){
return '5 bottles of soda on the wall, 5 bottles of soda, take one down pass it around 4 bottles of soda on the wall';

}
}
console.log(annoyingSong(5));


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 7 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -205,9 +276,21 @@ Using the grade function below do the following:
below should return 'you got an F'
*/

function grade(/*Your Code here */){
/*Your Code here */
}
function grade(number){
if(number >= 90){
return 'you got an A';
}else if(number < 90 && number >= 80){
return 'you got a B';
}else if(number < 80 && number >= 70){
return 'you got a C';
}else if(number < 70 && number >= 60){
return 'you got a D';
}else if(number < 60){
return 'you got an F';
}
}

console.log(grade(95));



Expand Down
Loading