From 38bf4e284f3a19e14d5fe0e70b8b614833c4c5cf Mon Sep 17 00:00:00 2001 From: Bryan Choe Date: Wed, 8 Feb 2017 08:24:37 -1000 Subject: [PATCH 01/10] first initial commit; --- exercises.js | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/exercises.js b/exercises.js index 8e1cbfc..533780d 100644 --- a/exercises.js +++ b/exercises.js @@ -1,21 +1,23 @@ /* If statements - Evaluates (or checks) a condition. If the condition is true, any statements in the subsequent code block are executed */ -var today = new Date(); + +/*var today = new Date(); 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. */ -if(today === "Friday"){ +/*if(today === "Friday"){ return "Let's Party!"; }else{ return "Get back to coding!"; -}; +};*/ + /* @@ -78,7 +80,7 @@ if(today === "Friday"){ * @param Datatype: String `word` * @return Datatype: String * - * The function will return the message "Word to Big Bird!", if the string passed into the function is a three-letter word. + * The function will return the message "Word to Big Bird!", if the string passed into the function is a three-letter word. * Console.log your result. */ @@ -92,7 +94,7 @@ if(today === "Friday"){ * @param Datatype: String `second` * @return Datatype: String * - * If the strings are equal, the function will return the message "You look mahvelous!" Otherwise, return the message: "I don't know who you are anymore." + * If the strings are equal, the function will return the message "You look mahvelous!" Otherwise, return the message: "I don't know who you are anymore." * Console.log your result. */ @@ -106,7 +108,7 @@ if(today === "Friday"){ * @param Datatype: String `second` * @return Datatype: String * - * If the strings are not equal, the function will return the message "Opposites do attract." Otherwise, return the message: "Cause it's like you're my mirror." + * If the strings are not equal, the function will return the message "Opposites do attract." Otherwise, return the message: "Cause it's like you're my mirror." * Console.log your result. */ @@ -121,7 +123,7 @@ if(today === "Friday"){ * * The function will return true if the number passed into the function is greater than 100, otherwise it will return false. * Console.log your result. -*/ +*/ /* @@ -136,7 +138,7 @@ if(today === "Friday"){ * * The function will return true if the sum of all the number values is greater than 30, otherwise it will return false. * Console.log your result. -*/ +*/ /* @@ -149,7 +151,7 @@ if(today === "Friday"){ * * The function will return true if the number passed in is an even integer, otherwise it will return false. * Console.log your result. -*/ +*/ /* @@ -163,7 +165,7 @@ if(today === "Friday"){ * * If BOTH values are 21 or over, the function will return the message: "Welcome to the Legends Lounge." Otherwise, it will return the message: "Chuck E Cheese is across the street." * Console.log your result. -*/ +*/ /* @@ -177,7 +179,7 @@ if(today === "Friday"){ * * If EITHER the number value is greater than or equal to 120 or the boolean value is true, then the function will return the message: "Congratulations on a job well done." Otherwise, return the message: "See you in summer school." * Console.log your result. -*/ +*/ /* @@ -190,7 +192,7 @@ if(today === "Friday"){ * * The function will return the message: "You are riding Honolulu's Rail.", if the number value is less than 50, otherwise it will return the message: "You are riding an Amtrak.", if the number value is less than 100, and return the message: "Now you ballin' in the Shinkansen!", if the number value is greater than or equal to 100. * Console.log your result. -*/ +*/ /* @@ -205,7 +207,7 @@ if(today === "Friday"){ * Console.log budget and doughnutBought. * Invoke your function again. * Console.log budget and doughnutBought again. -*/ +*/ /* @@ -225,7 +227,7 @@ for (var i = 0; i Date: Wed, 8 Feb 2017 15:45:40 -1000 Subject: [PATCH 02/10] completes #1 --- exercises.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/exercises.js b/exercises.js index 533780d..fe3259c 100644 --- a/exercises.js +++ b/exercises.js @@ -31,6 +31,17 @@ 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){ + if (age >= 18){ + return true; + } else { + return false + } +}; + +console.log('canVote:', canVote(15)); +console.log('canVote:', canVote(19)); + /* * #2 From 1fcfa16c92c2dace2439fda33452f574a5c0d0a9 Mon Sep 17 00:00:00 2001 From: Bryan Choe Date: Wed, 8 Feb 2017 15:50:48 -1000 Subject: [PATCH 03/10] adds exercise #3 --- exercises.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/exercises.js b/exercises.js index fe3259c..e6a829d 100644 --- a/exercises.js +++ b/exercises.js @@ -35,7 +35,7 @@ function canVote(age){ if (age >= 18){ return true; } else { - return false + return false; } }; @@ -55,6 +55,17 @@ console.log('canVote:', canVote(19)); * Console.log your result. */ +function login(password){ + if(password === 'test1234'){ + return 'Login Success!'; + } else { + return 'Login Fail!'; + } +} + +console.log('login:', login('test1234')); +console.log('login:', login('test4321')); + /* * #3 @@ -69,6 +80,16 @@ console.log('canVote:', canVote(19)); * Console.log your result. */ +function isGreaterThan(first, second){ + if(first > second){ + return true; + } else { + return false; + } +} + +console.log('Is Greater Than:', isGreaterThan(2,1)); +console.log('Is Greater Than:', isGreaterThan(1,2)); /* * #4 From 5512829964b6fbb1b8b92346f79af2c441578f5f Mon Sep 17 00:00:00 2001 From: Bryan Choe Date: Wed, 8 Feb 2017 16:15:54 -1000 Subject: [PATCH 04/10] finishes exercise #4 --- exercises.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/exercises.js b/exercises.js index e6a829d..07ba095 100644 --- a/exercises.js +++ b/exercises.js @@ -103,6 +103,17 @@ console.log('Is Greater Than:', isGreaterThan(1,2)); * Console.log your result. */ +function mustbeTrue(boo){ + if(boo === true){ + return true; + } else { + return false; + } +} + +console.log('mustbeTrue:', mustbeTrue(true)); +console.log('mustbeTrue:', mustbeTrue(false)); + /* * #5 From 99514804a1d3af6eaab22b5895fce7c42913ffaf Mon Sep 17 00:00:00 2001 From: Bryan Choe Date: Wed, 8 Feb 2017 16:20:48 -1000 Subject: [PATCH 05/10] finishes exercise 5 --- exercises.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/exercises.js b/exercises.js index 07ba095..f8090f1 100644 --- a/exercises.js +++ b/exercises.js @@ -127,6 +127,16 @@ console.log('mustbeTrue:', mustbeTrue(false)); * Console.log your result. */ +function bigBird(word){ + if(word === word.substring(0,3)){ + return 'Word to Big Bird'; + } else { + return 'Nah'; + } +} + +console.log(bigBird('che')); + /* * #6 From 061f4fa59a26d6f7d4282425eb39ecab9c0f47da Mon Sep 17 00:00:00 2001 From: Bryan Choe Date: Wed, 8 Feb 2017 18:39:58 -1000 Subject: [PATCH 06/10] adds doughnut assignment --- exercises.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/exercises.js b/exercises.js index f8090f1..bc5d357 100644 --- a/exercises.js +++ b/exercises.js @@ -262,6 +262,26 @@ console.log(bigBird('che')); * Console.log budget and doughnutBought again. */ +var budget = 20; +var doughnutPrice = 5; +var doughnutBought = 0; + +function buyDoughnut(){ + if (budget >= doughnutPrice){ + budget = budget - doughnutPrice; + doughnutBought++; + } else { + return 'not enough funds'; + } +} + +console.log(budget); +console.log(doughnutBought); +buyDoughnut(); +console.log(budget); +console.log(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. From 4a340bf3464d1af07bdd1f148e788836f1f343af Mon Sep 17 00:00:00 2001 From: Bryan Choe Date: Wed, 8 Feb 2017 19:31:46 -1000 Subject: [PATCH 07/10] adds random student generator --- exercises.js | 16 ++++++++++++++-- random.js | 6 ++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 random.js diff --git a/exercises.js b/exercises.js index bc5d357..8cb28c1 100644 --- a/exercises.js +++ b/exercises.js @@ -1,7 +1,19 @@ +//random student generator + +var students = ['Christine', 'Jacob', 'Anthony', 'Earnest', 'Ann', 'Ella', 'James', 'Joshua', 'Kaleo', 'Ulu', 'Gaganvir']; + +var randomIndex = Math.floor(Math.random() * students.length); +var randomElement = students[randomIndex]; + +console.log('Student:',randomElement); + + /* If statements - Evaluates (or checks) a condition. If the condition is true, any statements in the subsequent code block are executed */ + + /*var today = new Date(); if(today === "Friday"){ @@ -37,7 +49,7 @@ function canVote(age){ } else { return false; } -}; +} console.log('canVote:', canVote(15)); console.log('canVote:', canVote(19)); @@ -269,7 +281,7 @@ var doughnutBought = 0; function buyDoughnut(){ if (budget >= doughnutPrice){ budget = budget - doughnutPrice; - doughnutBought++; + return doughnutBought++; } else { return 'not enough funds'; } diff --git a/random.js b/random.js new file mode 100644 index 0000000..ffdb878 --- /dev/null +++ b/random.js @@ -0,0 +1,6 @@ +var students = ['Christine', 'Jacob', 'Anthony', 'Earnest', 'Ann', 'Ella', 'James', 'Joshua', 'Kaleo', 'Ulu', 'Gaganvir']; + +var randomIndex = Math.floor(Math.random() * students.length); +var randomElement = students[randomIndex]; + +console.log(randomElement); From b631abcdc45daf277f37c4f0f31bf836cdadf57d Mon Sep 17 00:00:00 2001 From: Bryan Choe Date: Wed, 8 Feb 2017 19:32:37 -1000 Subject: [PATCH 08/10] changes --- random.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/random.js b/random.js index ffdb878..4d2b1c5 100644 --- a/random.js +++ b/random.js @@ -1,4 +1,16 @@ -var students = ['Christine', 'Jacob', 'Anthony', 'Earnest', 'Ann', 'Ella', 'James', 'Joshua', 'Kaleo', 'Ulu', 'Gaganvir']; +var students = [ + 'Christine', + 'Jacob', + 'Anthony', + 'Earnest', + 'Ann', + 'Ella', + 'James', + 'Joshua', + 'Kaleo', + 'Ulu', + 'Gaganvir' + ]; var randomIndex = Math.floor(Math.random() * students.length); var randomElement = students[randomIndex]; From 62e6a89b9dde87ae61c20231fae3007e701e622f Mon Sep 17 00:00:00 2001 From: Bryan Choe Date: Mon, 13 Mar 2017 20:03:33 -1000 Subject: [PATCH 09/10] js-logic adds additional instruction to #14 --- exercises.js | 41 ++++++++++++++++++++--------------------- random.js | 2 +- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/exercises.js b/exercises.js index 8cb28c1..ca36207 100644 --- a/exercises.js +++ b/exercises.js @@ -1,13 +1,3 @@ -//random student generator - -var students = ['Christine', 'Jacob', 'Anthony', 'Earnest', 'Ann', 'Ella', 'James', 'Joshua', 'Kaleo', 'Ulu', 'Gaganvir']; - -var randomIndex = Math.floor(Math.random() * students.length); -var randomElement = students[randomIndex]; - -console.log('Student:',randomElement); - - /* If statements - Evaluates (or checks) a condition. If the condition is true, any statements in the subsequent code block are executed */ @@ -269,6 +259,7 @@ console.log(bigBird('che')); * * Create a function named `buyDoughnut` which takes NO parameters. * When the function is invoked, the budget will be decreased by the doughnutPrice and doughnutBought will increase by 1. + * Your function should return a message 'Not enough money' if you run out of money in your budget * Console.log budget and doughnutBought. * Invoke your function again. * Console.log budget and doughnutBought again. @@ -362,6 +353,12 @@ for (var i = 0; i Date: Wed, 13 Sep 2017 14:45:31 -1000 Subject: [PATCH 10/10] adds comments --- exercises.js | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/exercises.js b/exercises.js index ca36207..57d9bbb 100644 --- a/exercises.js +++ b/exercises.js @@ -2,8 +2,6 @@ If statements - Evaluates (or checks) a condition. If the condition is true, any statements in the subsequent code block are executed */ - - /*var today = new Date(); if(today === "Friday"){ @@ -20,8 +18,6 @@ If/else statements = Evaluates (or checks) a condition. If the condition is true return "Get back to coding!"; };*/ - - /* * #1 * Function - canVote @@ -33,7 +29,7 @@ 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){ +/*function canVote(age){ if (age >= 18){ return true; } else { @@ -42,7 +38,7 @@ function canVote(age){ } console.log('canVote:', canVote(15)); -console.log('canVote:', canVote(19)); +console.log('canVote:', canVote(19));*/ /* @@ -57,7 +53,7 @@ console.log('canVote:', canVote(19)); * Console.log your result. */ -function login(password){ +/*function login(password){ if(password === 'test1234'){ return 'Login Success!'; } else { @@ -66,7 +62,7 @@ function login(password){ } console.log('login:', login('test1234')); -console.log('login:', login('test4321')); +console.log('login:', login('test4321'));*/ /* @@ -82,7 +78,7 @@ console.log('login:', login('test4321')); * Console.log your result. */ -function isGreaterThan(first, second){ +/*function isGreaterThan(first, second){ if(first > second){ return true; } else { @@ -91,7 +87,7 @@ function isGreaterThan(first, second){ } console.log('Is Greater Than:', isGreaterThan(2,1)); -console.log('Is Greater Than:', isGreaterThan(1,2)); +console.log('Is Greater Than:', isGreaterThan(1,2));*/ /* * #4 @@ -105,7 +101,7 @@ console.log('Is Greater Than:', isGreaterThan(1,2)); * Console.log your result. */ -function mustbeTrue(boo){ +/*function mustbeTrue(boo){ if(boo === true){ return true; } else { @@ -114,7 +110,7 @@ function mustbeTrue(boo){ } console.log('mustbeTrue:', mustbeTrue(true)); -console.log('mustbeTrue:', mustbeTrue(false)); +console.log('mustbeTrue:', mustbeTrue(false));*/ /* @@ -129,7 +125,7 @@ console.log('mustbeTrue:', mustbeTrue(false)); * Console.log your result. */ -function bigBird(word){ +/*function bigBird(word){ if(word === word.substring(0,3)){ return 'Word to Big Bird'; } else { @@ -137,7 +133,7 @@ function bigBird(word){ } } -console.log(bigBird('che')); +console.log(bigBird('che'));*/ /* @@ -265,7 +261,7 @@ console.log(bigBird('che')); * Console.log budget and doughnutBought again. */ -var budget = 20; +/*var budget = 20; var doughnutPrice = 5; var doughnutBought = 0; @@ -283,7 +279,7 @@ console.log(doughnutBought); buyDoughnut(); console.log(budget); console.log(doughnutBought); - +*/ /* @@ -337,6 +333,7 @@ for (var i = 0; i