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

const votingAge = 18;

if (votingAge < 18) {
console.log("false");
} else {
console.log("true")
};

// this one logs true!


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

let valueOne = 12;

let valueTwo = 16;

if (valueTwo >= 15) {
valueOne = 6;
}

console.log(valueOne);

//valueOne equals 6 because valueTwo is greater than or equal to 15



Expand All @@ -46,6 +65,14 @@ Do the following:
HINT: look up the Number method
*/

let x = 1999;

x.toString();

console.log(x.toString());

"1999"




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

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



Expand Down Expand Up @@ -107,10 +134,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(weight, years){
if (years < 1) {
if (years <= .3333) {
return weight * .1
}

else if

(years < .6666){
return weight * .05
}
}
}

// console.log(hungryDog(5, .6665));



/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 4 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -134,9 +173,43 @@ Use the game function below to do the following:
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*/
function game(user,computer){
if(computer === 0){
return "rock";
}else if(computer === 1){
return "paper";
}else if(computer === 2){
return "scissors";
}

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


game('rock',computer);



Expand All @@ -151,10 +224,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){
const miles = km * 0.621371;
return miles;
}
console.log(miles(10));


//Task 5b - Feet to CM
Expand All @@ -165,8 +239,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(cm){
const feet = cm/30.48;
return feet;
}


Expand Down Expand Up @@ -201,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(num){
if(num < 100 && num >= 90){
return 'you got an A';
}else if(num <90 && num >= 80){
return 'you got a B';
}else if(num < 80 && num >= 70){
return 'you got a C';
}else if(num < 70 && num >= 60){
return 'you got a D';
}else if(num < 60){
return 'you got an F';
}
}

console.log('grade function', grade(60));



Expand Down