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


let votingAge = 19;

if (votingAge > 18) {
console.log("You can Vote!")
} else if (votingAge === 18) {
console.log("You can still Vote!")
} else if (votingAge < 18) {
console.log("You can't Vote :(")
}

/*
Task 1b - Values
Expand All @@ -31,7 +39,12 @@ Do the following:
HINT: no function required
*/

let num1 = 20
let num2 = 7

if (num1 > num2) {
console.log(num1 - num2)
}



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



let num3 = parseInt("1999")
console.log(num3)

/*
Task 1d - Multiply
Expand All @@ -58,8 +71,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 +87,8 @@ Do the following:
3. Return the newly calculated age
*/

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


Expand Down Expand Up @@ -107,8 +120,16 @@ 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 {
return weight * .03;
}
}
}


Expand All @@ -133,7 +154,22 @@ Use the game function below to do the following:
*/

function game(user, computer){
/*add your code here*/
if (computer < 0.33) {
computer = "rock";
} else if (computer < 0.66) {
computer = "paper"
} else if (computer < 0.99) {
computer = "scissors"
}
if (user === "rock" && computer === "scissors" || user === "paper" && computer === "rock" || user === "scissors" && computer === "paper") {
return "you win!"
}
else if (computer === "rock" && user === "scissors" || computer === "paper" && user === "rock" || computer === "scissors" && user === "paper") {
return "you lose!"
}
else if (computer === "rock" && user === "rock" || computer === "paper" && user === "paper" || computer === "scissors" && user === "scissors") {
return "it's a tie"
}
}


Expand All @@ -149,8 +185,8 @@ 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
}


Expand All @@ -163,8 +199,8 @@ 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
}


Expand All @@ -179,9 +215,12 @@ 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(){
for (let number = 5; number >= 0; number --) {
return `${number} bottles of soda on the wall, ${number} bottles of soda, take one down pass it around ${number-1} bottles of soda on the wall`
}
}
console.log(annoyingSong())


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

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


Expand Down