From c0c39a29c29bc779226b8df70ce5d8e1646976e1 Mon Sep 17 00:00:00 2001 From: Chase Turner Date: Thu, 13 Jul 2017 18:33:20 -0500 Subject: [PATCH 1/3] Data-Types Commit 1 --- 01week/javascripting/chance.js | 21 ++++++++++ 01week/javascripting/data-types.js | 61 ++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 01week/javascripting/chance.js create mode 100644 01week/javascripting/data-types.js diff --git a/01week/javascripting/chance.js b/01week/javascripting/chance.js new file mode 100644 index 000000000..d26e933ee --- /dev/null +++ b/01week/javascripting/chance.js @@ -0,0 +1,21 @@ +'use strict'; +/**Pick a random student from this class +*Store names in a variable-array +*generate a random number, less than amount in class +*apply index to array +*from that array, pick a random name +*return a name +**/ + +const studentArray = ['dude','person','thing']; + +function randomNumberInRange(top, bottom) { + return Math.floor (Math.random()*(1 + top - bottom ))+bottom; +} + + +function generateRandomName(){ + const index = randomNumberInRange(studentArray.length-1, 0); + return studentArray[index]; +} +console.log(generateRandomName()); diff --git a/01week/javascripting/data-types.js b/01week/javascripting/data-types.js new file mode 100644 index 000000000..70f48a894 --- /dev/null +++ b/01week/javascripting/data-types.js @@ -0,0 +1,61 @@ + +function returnDate(){ + const date=new Date(); + return date;} + +console.log(returnDate()) + + +function NtoS() { + const num = 7; + const n = num.toString(); + return (n); +} + +console.log(NtoS()); + +function stuff(){ + const s = parseInt('77'); + return (s); +} +console.log(stuff()); + + +function add(){ + const sum = 3+4; + return (sum); +} +console.log (add()); + + + +function twotrue(){ + const x=5 + const y=5 + if (x===y){ + return('true'); + } + +} +console.log(twotrue()); + +function onetrue(){ + const x2=5 + const y2='5' + if (x2===5 && y2!==5){ + return('1true'); + } +} +console.log(onetrue()); + +console.log(typeof x); +console.log(typeof y2); + +function allfalse(){ + const x3=5 + const y3='5' + if (x3!=='5' && y3!==5){ + return('false'); + } +} +console.log(allfalse()); From 7a5df42b5ba996f7737bc6d19e3a0cf049c9a382 Mon Sep 17 00:00:00 2001 From: Chase Turner Date: Thu, 13 Jul 2017 20:37:51 -0500 Subject: [PATCH 2/3] Rock Paper Scissors Function Created Commit 1 --- 01week/rockPaperScissors.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/01week/rockPaperScissors.js b/01week/rockPaperScissors.js index 16f58790a..053079177 100644 --- a/01week/rockPaperScissors.js +++ b/01week/rockPaperScissors.js @@ -8,11 +8,27 @@ const rl = readline.createInterface({ }); -function rockPaperScissors(hand1, hand2) { - // Write code here + // Write code here +function rockPaperScissors(hand1, hand2){ + if (hand1 === hand2){ + return "It's a tie!"; + }else if (hand1==='rock' && hand2==='paper') { + return "Hand two wins!"; + }else if (hand1==='rock' && hand2 === 'scissors') { + return "Hand one wins!"; + }else if (hand1 === 'paper' && hand2 === 'scissors') { + return "Hand two wins!"; + }else if (hand1 === 'paper' && hand2 === 'rock') { + return "Hand one wins!"; + }else if (hand1 === 'scissors' && hand2 === 'paper') { + return "Hand one wins!"; + }else if (hand1 === 'scissors' && hand2 === 'rock') { + return "Hand 2 wins!"; + } } +console.log(rockPaperScissors()); function getPrompt() { rl.question('hand1: ', (answer1) => { From a587b8d8a20a9b2b3bf6c11bb53b9afad10eb1ca Mon Sep 17 00:00:00 2001 From: Chase Turner Date: Tue, 18 Jul 2017 18:24:48 -0500 Subject: [PATCH 3/3] RockPaperScissors 1st Commit --- 01week/rockPaperScissors.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/01week/rockPaperScissors.js b/01week/rockPaperScissors.js index 053079177..00136ba70 100644 --- a/01week/rockPaperScissors.js +++ b/01week/rockPaperScissors.js @@ -12,7 +12,11 @@ const rl = readline.createInterface({ // Write code here function rockPaperScissors(hand1, hand2){ - if (hand1 === hand2){ + if (hand1 === 'rock' && hand2 === 'rock') { + return "It's a tie!"; + }else if (hand1 === 'paper' && hand2 === 'paper') { + return "It's a tie!"; + }else if (hand1 === 'scissors' && hand2 === 'scissors') { return "It's a tie!"; }else if (hand1==='rock' && hand2==='paper') { return "Hand two wins!";