From ec218c4dda4611d1bfd62d3c530bb2238f0b4035 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 11 Oct 2018 17:33:36 -0500 Subject: [PATCH 1/6] initial commit --- 01week/datatypes.js | 54 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/01week/datatypes.js b/01week/datatypes.js index e69de29bb..4d284791b 100644 --- a/01week/datatypes.js +++ b/01week/datatypes.js @@ -0,0 +1,54 @@ +const day = date.getDay(); +const hour = date.getHours(); +const minute = date.getMinutes(); +console.log("today is " + [day] + " " + [hour] + ":" + [minute]); + + +const number = (x) => { + console.log(toString(x)); +} +number("84"); + + +const string = (number) => { + console.log(Number(number)); +} +string(48); + + +const type = (datatype) => { + console.log(typeof datatype); +} +type(false); + + +const add = (x, y) => { + console.log (x + y); +} +add(4,6); + + +const a = 6; +const b = 9; +const c = 12; + +function twoTrue() { + if (b>a && c>b) { + console.log(a+b); + } +} +twoTrue(); + +const oneTrue = (x,y) => { + if (x>y || x==y) { + console.log(x+y); + } +} +oneTrue(3,1); + +const noneTrue = (x,y) => { + if (!x>y && !x==y) { + console.log(x+y); + } +} +noneTrue(1,3); \ No newline at end of file From d2ddbf2cf6c476c25c243bfb63953831d16b210d Mon Sep 17 00:00:00 2001 From: Erlangga Ramzy Date: Thu, 11 Oct 2018 20:33:15 -0500 Subject: [PATCH 2/6] whiteboarding --- 01week/rockPaperScissors.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/01week/rockPaperScissors.js b/01week/rockPaperScissors.js index 16f58790a..2593d2473 100644 --- a/01week/rockPaperScissors.js +++ b/01week/rockPaperScissors.js @@ -7,6 +7,10 @@ const rl = readline.createInterface({ output: process.stdout }); +//hand1 enters move, hand2 move (done for us) +//check to see if move is valid +//if moves invalid redo moves (getprompt) +//check win state (loss or tie) function rockPaperScissors(hand1, hand2) { @@ -14,6 +18,10 @@ function rockPaperScissors(hand1, hand2) { } +function checkValid() + +function checkWin() + function getPrompt() { rl.question('hand1: ', (answer1) => { rl.question('hand2: ', (answer2) => { From 904c2715ada0a0c796b65284d9f1da8bbca53b54 Mon Sep 17 00:00:00 2001 From: Erlangga Ramzy Date: Tue, 16 Oct 2018 23:07:36 -0500 Subject: [PATCH 3/6] finished rock paper scissors --- 01week/rockPaperScissors.js | 53 ++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/01week/rockPaperScissors.js b/01week/rockPaperScissors.js index 2593d2473..b764d5f95 100644 --- a/01week/rockPaperScissors.js +++ b/01week/rockPaperScissors.js @@ -7,20 +7,53 @@ const rl = readline.createInterface({ output: process.stdout }); -//hand1 enters move, hand2 move (done for us) -//check to see if move is valid -//if moves invalid redo moves (getprompt) -//check win state (loss or tie) +// hand1 enters move, hand2 move (done for us) +// check to see if move is valid. checkValid +// if moves invalid redo moves (getprompt) +// check win state (loss or tie). checkWin function rockPaperScissors(hand1, hand2) { - - // Write code here - + if (checkValid(hand1) && checkValid(hand2)) { + if (hand1 == hand2) { + return "It's a tie!"; + } + // hand1 = rock + else if (hand1 == "rock") { + if (hand2 == "scissors") { + return "Hand one wins!"; + } else { + return "Hand two wins!"; + }; + } + // hand1 = paper + else if (hand1 == "paper") { + if (hand2 == "rock") { + return "Hand one wins!"; + } else { + return "Hand two wins!"; + }; + } + // hand1 = scissors + else if (hand1 == "scissors") { + if (hand2 == "paper") { + return "Hand one wins!"; + } else { + return "Hand two wins!"; + } + } + } else { + console.log('Please redo'); + } } -function checkValid() - -function checkWin() +const checkValid = (hand) => { + const lowerCase = hand.toLowerCase() + if (lowerCase == 'rock' || lowerCase == 'paper' || lowerCase == 'scissors') { + return true; + } else { + return false; + } +} function getPrompt() { rl.question('hand1: ', (answer1) => { From 2d5afaacfc69e9a84709b68ee4afc70268065876 Mon Sep 17 00:00:00 2001 From: Erlangga Ramzy Date: Tue, 16 Oct 2018 23:20:25 -0500 Subject: [PATCH 4/6] finished rockpaperscissors, 2nd commit couldnt find the first one --- 01week/rockPaperScissors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/01week/rockPaperScissors.js b/01week/rockPaperScissors.js index b764d5f95..11ea504f5 100644 --- a/01week/rockPaperScissors.js +++ b/01week/rockPaperScissors.js @@ -10,7 +10,7 @@ const rl = readline.createInterface({ // hand1 enters move, hand2 move (done for us) // check to see if move is valid. checkValid // if moves invalid redo moves (getprompt) -// check win state (loss or tie). checkWin +// check win state (loss or tie). checkWin() function rockPaperScissors(hand1, hand2) { if (checkValid(hand1) && checkValid(hand2)) { From 289753d11cc5ec78c1d28e5a0879859078766342 Mon Sep 17 00:00:00 2001 From: Erlangga Ramzy Date: Tue, 16 Oct 2018 23:46:06 -0500 Subject: [PATCH 5/6] deleted dataypes.js --- 01week/datatypes.js | 54 --------------------------------------------- 02week/pigLatin.js | 10 +++++++++ 2 files changed, 10 insertions(+), 54 deletions(-) delete mode 100644 01week/datatypes.js diff --git a/01week/datatypes.js b/01week/datatypes.js deleted file mode 100644 index 4d284791b..000000000 --- a/01week/datatypes.js +++ /dev/null @@ -1,54 +0,0 @@ -const day = date.getDay(); -const hour = date.getHours(); -const minute = date.getMinutes(); -console.log("today is " + [day] + " " + [hour] + ":" + [minute]); - - -const number = (x) => { - console.log(toString(x)); -} -number("84"); - - -const string = (number) => { - console.log(Number(number)); -} -string(48); - - -const type = (datatype) => { - console.log(typeof datatype); -} -type(false); - - -const add = (x, y) => { - console.log (x + y); -} -add(4,6); - - -const a = 6; -const b = 9; -const c = 12; - -function twoTrue() { - if (b>a && c>b) { - console.log(a+b); - } -} -twoTrue(); - -const oneTrue = (x,y) => { - if (x>y || x==y) { - console.log(x+y); - } -} -oneTrue(3,1); - -const noneTrue = (x,y) => { - if (!x>y && !x==y) { - console.log(x+y); - } -} -noneTrue(1,3); \ No newline at end of file diff --git a/02week/pigLatin.js b/02week/pigLatin.js index 046434c94..5955a2991 100644 --- a/02week/pigLatin.js +++ b/02week/pigLatin.js @@ -1,3 +1,13 @@ +//planning +//input text +//check to see if valid (make sure string, check if any numbers), if not ask to re enter a word. checkValid() +//check for uppercase, turn all to lowercase. fixCase() +//check to see if start with vowel, if vowel, add yay to end. checkVowel() return it back +//turn entered word to array(splice). turnIntoList() +//go through array until first vowel(loop until vowel). checkConsonent() +//take letters until first vowel and put to the end (pop) and add ay. addVowelAy() + + 'use strict'; const assert = require('assert'); From 4b870975661295f203ab1d3262fb33c34e9bbe87 Mon Sep 17 00:00:00 2001 From: Erlangga Ramzy Date: Tue, 16 Oct 2018 23:53:10 -0500 Subject: [PATCH 6/6] deleted piglatin from rock-paper-scissors branch --- 02week/pigLatin.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/02week/pigLatin.js b/02week/pigLatin.js index 5955a2991..046434c94 100644 --- a/02week/pigLatin.js +++ b/02week/pigLatin.js @@ -1,13 +1,3 @@ -//planning -//input text -//check to see if valid (make sure string, check if any numbers), if not ask to re enter a word. checkValid() -//check for uppercase, turn all to lowercase. fixCase() -//check to see if start with vowel, if vowel, add yay to end. checkVowel() return it back -//turn entered word to array(splice). turnIntoList() -//go through array until first vowel(loop until vowel). checkConsonent() -//take letters until first vowel and put to the end (pop) and add ay. addVowelAy() - - 'use strict'; const assert = require('assert');