Skip to content
Closed
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
97 changes: 96 additions & 1 deletion exercises.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ if(today === "Friday"){
return "Let's Party!";
};*/


/*
If/else statements = Evaluates (or checks) a condition. If the condition is true, the first code block is executed. If the condition is false, the second code block is executed instead.
*/
Expand All @@ -29,6 +30,12 @@ If/else statements = Evaluates (or checks) a condition. If the condition is true
* The function will return true if the number passed into the function is equal to or greater than Hawaii's voting age. Console.log your result.
*/

function canVote(age) {

return age >= 16
}

console.log(canVote(16));

/*
* #2
Expand All @@ -42,6 +49,13 @@ If/else statements = Evaluates (or checks) a condition. If the condition is true
* Console.log your result.
*/

function login(password) {
return password === "test1234" ? "Login Success" : "Login Failed";
}

console.log(login("test1234"));
console.log(login("test"));


/*
* #3
Expand All @@ -56,6 +70,12 @@ If/else statements = Evaluates (or checks) a condition. If the condition is true
* Console.log your result.
*/

function isGreaterThan(first, second) {
return first > second;
}

console.log(isGreaterThan(1,2));
console.log(isGreaterThan(2,1));


/*
Expand All @@ -70,6 +90,12 @@ If/else statements = Evaluates (or checks) a condition. If the condition is true
* Console.log your result.
*/

function mustBeTrue(boo) {
return boo === true;
}

console.log(mustBeTrue("boo"));
console.log(mustBeTrue(true));


/*
Expand All @@ -84,7 +110,13 @@ If/else statements = Evaluates (or checks) a condition. If the condition is true
* Console.log your result.
*/


function bigBird(word) {
if (word.length === 3) {
return "Word to Big Bird!";
}
}
console.log(bigBird("abc"));
console.log(bigBird("abcd"));

/*
* #6
Expand All @@ -99,6 +131,13 @@ If/else statements = Evaluates (or checks) a condition. If the condition is true
* Console.log your result.
*/

function isEqual(first, second) {
return first === second ? "You look mahvelous!" : "I don't know who you are anymore.";
}

console.log(isEqual("a","b"));
console.log(isEqual("a","a"));


/*
* #7
Expand All @@ -113,6 +152,12 @@ If/else statements = Evaluates (or checks) a condition. If the condition is true
* Console.log your result.
*/

function notEqual(first, second) {
return first !== second ? "Opposites do attract." : "Cause it's like you're my mirror.";
}

console.log(notEqual("a","b"));
console.log(notEqual("a","a"));

/*
* #8
Expand All @@ -126,6 +171,12 @@ If/else statements = Evaluates (or checks) a condition. If the condition is true
* Console.log your result.
*/

function spareChange(money) {
return money > 100;
}

console.log(spareChange(100));
console.log(spareChange(101));


/*
Expand All @@ -142,6 +193,12 @@ If/else statements = Evaluates (or checks) a condition. If the condition is true
* Console.log your result.
*/

function dirty30(one, two, three) {
return (one + two + three) > 30;
}

console.log(dirty30(-1,-2,100));
console.log(dirty30(-1,-2,25));


/*
Expand All @@ -156,6 +213,12 @@ If/else statements = Evaluates (or checks) a condition. If the condition is true
* Console.log your result.
*/

function evenStevens(num) {
return num % 2 === 0;
}

console.log(evenStevens(1));
console.log(evenStevens(2));



Expand All @@ -172,6 +235,13 @@ If/else statements = Evaluates (or checks) a condition. If the condition is true
* Console.log your result.
*/

function daClub(cover, age) {
return (cover >= 21) && (age >= 21) ? "Welcome to the Legends Lounge." : "Chuck E Cheese is across the street.";
}

console.log(daClub(21,21));
console.log(daClub(19,21));


/*
* #12
Expand All @@ -186,6 +256,14 @@ If/else statements = Evaluates (or checks) a condition. If the condition is true
* Console.log your result.
*/

function graduation(credits, thesis) {
return (credits >= 120) || (thesis === true) ? "Congratulations on a job well done." : "See you in summer school.";
}

console.log(graduation(120, true));
console.log(graduation(1, false));
console.log(graduation(1, "d"));



/*
Expand All @@ -200,6 +278,23 @@ If/else statements = Evaluates (or checks) a condition. If the condition is true
* Console.log your result.
*/

function moneyTrain(speed) {
var message = "";
if (speed < 50) {
message = "You are riding Honolulu's Rail.";
} else if (speed < 100) {
message = "You are riding an Amtrak.";
} else if (speed >= 100) {
message = "Now you ballin' in the Shinkansen!";
}
return message;

}

console.log(moneyTrain(10));
console.log(moneyTrain(60));
console.log(moneyTrain(101));


/*
* #14
Expand Down