Skip to content

Commit

Permalink
refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
victorlhlee committed Mar 13, 2017
1 parent b27e4fc commit a29ade1
Showing 1 changed file with 73 additions and 36 deletions.
109 changes: 73 additions & 36 deletions solutions.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ function canVote(age){
}
console.log("1. canVote: ", canVote(19));



/*
* #2
* Function - login
Expand All @@ -57,7 +55,6 @@ function login(password){
return "Login Success!";
}
}

console.log(login("test1234"));
/*
* #3
Expand All @@ -77,11 +74,10 @@ function isGreaterThan(first, second){
return true;
}
}

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

var showResult = isGreaterThan(5, 1);
console.log(showResult);
console.log("isGreaterThan: ", showResult);

/*
* #4
Expand All @@ -103,8 +99,7 @@ function mustBeTrue(boo){
}

}

console.log(mustBeTrue(true));
console.log("mustBeTrue: ", mustBeTrue(true));

/*
* #5
Expand All @@ -118,15 +113,13 @@ console.log(mustBeTrue(true));
* Console.log your result.
*/

var arr = ["apple", "banana", "orange"];

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

console.log(bigBird(arr));
console.log("bigBird: ", bigBird("cat"));

/*
* #6
Expand All @@ -141,6 +134,14 @@ console.log(bigBird(arr));
* Console.log your result.
*/

function isEqual(first, second){
if(first === second){
return "You look mahvelous!";
}else{
return "I don't know who you are anymore.";
}
}
console.log(isEqual("ying", "yang"));

/*
* #7
Expand All @@ -155,6 +156,14 @@ console.log(bigBird(arr));
* Console.log your result.
*/

function notEqual(first, second){
if(first !== second){
return "Opposites do attract.";
}else{
return "Cause it's like you're my mirror." ;
}
}
console.log(notEqual("sweet", "sour"));

/*
* #8
Expand All @@ -168,9 +177,15 @@ console.log(bigBird(arr));
* Console.log your result.
*/

function spareChange(money){
if(money >100){
return true;
}else{
return false;
}
}



console.log("spareChange: ", spareChange(101));

/*
* #9
Expand All @@ -186,7 +201,15 @@ console.log(bigBird(arr));
* Console.log your result.
*/


function dirty30(one, two, three){
var sum = one + two + three;
if(sum > 30){
return true;
}else{
return false;
}
}
console.log("dirty30: ", dirty30(10, 20, 25));

/*
* #10
Expand All @@ -207,11 +230,9 @@ function evenStevens(num){
return false;
}
}

console.log("evenStevens ", evenStevens(8));



/*
* #11
* Function - daClub
Expand All @@ -226,6 +247,15 @@ console.log("evenStevens ", evenStevens(8));
*/


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

/*
* #12
* Function - graduation
Expand All @@ -240,16 +270,14 @@ console.log("evenStevens ", evenStevens(8));
*/

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

}

var gradResults = graduation(120, true);
console.log(gradResults);
var gradResults = graduation(100, true);
console.log("graduuation: ", gradResults);

/*
* #13
Expand All @@ -263,6 +291,17 @@ console.log(gradResults);
* Console.log your result.
*/

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


/*
* #14
Expand All @@ -283,19 +322,19 @@ var doughnutPrice = 5;
var doughnutBought = 0;

function buyDoughnut(){
if(budget >= doughnutPrice){
budget = budget - doughnutPrice;
//budget -= doughnutPrice;
if(budget >= doughnutPrice){
budget -= doughnutPrice;
doughnutBought++;
}
}


buyDoughnut();
console.log("budget ", budget);
console.log("bought ", doughnutBought);




/*
For loops - A for loop checks a condition a specific number of times and allows us to execute a code block and evaluate a condition to determine if our loop should run again.
Expand Down Expand Up @@ -323,13 +362,19 @@ for (var i = 0; i<toyotaModels.length; i++){
* "Player: 5"
*/

for(var i = 1; i<=5; i++){
console.log("player ", i);
}

/*
* #16
* Create a for loop that will iterate and console.log each item in the array below:
*/
var myFavFoods = ["lemon bar", "carrot cake", "nachos", "bacon cheeseburger", "ramen", "sweet potato fries", "chimichanga"];

for(var i = 0; i<myFavFoods.length; i++){
console.log(myFavFoods[i]);
}

/*
* #17
Expand All @@ -349,9 +394,8 @@ for (var i = 0; i<toyotaModels.length; i++){

var numArray = [22, 33, 44, 55, 66];

var total = 0;

function sumItUp(arr){
var total = 0;
for(var i = 0; i<arr.length; i++){
console.log(arr[i]);
total += arr[i]; // total = total + arr[i];
Expand All @@ -361,6 +405,7 @@ function sumItUp(arr){
}

console.log("sumitup ", sumItUp(numArray));

/*
* #18
* Function - allStars
Expand Down Expand Up @@ -388,13 +433,9 @@ console.log("sumitup ", sumItUp(numArray));
}
}
}

allStars(players);
console.log(east);
console.log(west);



console.log("east: ", east);
console.log("west: ", west);

/*
* #19
Expand All @@ -420,10 +461,8 @@ function subways(special){

}
return special;

}


subways(subOftheDay);
console.log(subOftheDay);

Expand Down Expand Up @@ -451,9 +490,7 @@ Final Boss
}
console.log(newArr);
return newArr;

}

removeLetter(phrase);


Expand Down

0 comments on commit a29ade1

Please sign in to comment.