From 19cb87dd9cfcd46687a075c3fcb970c66bcf84c0 Mon Sep 17 00:00:00 2001 From: walzer85 Date: Tue, 3 Oct 2017 19:34:05 -0500 Subject: [PATCH 01/10] initial commit --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index a8de93e90..ffe101bd4 100644 --- a/index.html +++ b/index.html @@ -5,6 +5,6 @@ -

Hello World!

+

Hello Eric, how are you!

From 10f989e17b82d25201df00c05f6ce4895f8968be Mon Sep 17 00:00:00 2001 From: walzer85 Date: Tue, 3 Oct 2017 20:45:50 -0500 Subject: [PATCH 02/10] wrote comments for first assignment --- 01week/datatypes.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/01week/datatypes.js b/01week/datatypes.js index e69de29bb..57708f111 100644 --- a/01week/datatypes.js +++ b/01week/datatypes.js @@ -0,0 +1,17 @@ +//returns current date and time +//make a today var, which is assigned a new date instance +//make new var to store the today var and toDateString method +//use var today with toTimeString method + +//create a var to convert. +//input a number into var convert +//use convert and toString() method to make the number a string + +//first method to convert string to number +//input a string into parseInt() method and returns number +//or... +//set var to a string +//use Number() method + +//tells what type of datatype your input is +//use the typeOf method From 471521450b5755fdb4eaa27891fae149ebb9f53c Mon Sep 17 00:00:00 2001 From: walzer85 Date: Thu, 5 Oct 2017 06:31:45 -0500 Subject: [PATCH 03/10] finished most steps, need to look at first one --- 01week/datatypes.js | 48 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/01week/datatypes.js b/01week/datatypes.js index 57708f111..6f4eeaccb 100644 --- a/01week/datatypes.js +++ b/01week/datatypes.js @@ -1,17 +1,63 @@ +`use strict` + //returns current date and time //make a today var, which is assigned a new date instance //make new var to store the today var and toDateString method //use var today with toTimeString method +var today = new date(dateString); +console.log(today); + //create a var to convert. //input a number into var convert //use convert and toString() method to make the number a string +var num = 13 +var n = num.toString + //first method to convert string to number //input a string into parseInt() method and returns number //or... //set var to a string //use Number() method +var str = `15 Years` +var int = parseInt(str) + //tells what type of datatype your input is -//use the typeOf method +//create a variable of any main datatype +//use the typeOf method on the variable + +var dataType = `words words words` +var result = typeOf(dataType) + +//make two variables that use parseInt() method +//add the two variables with ansD. + +var numOne = parseInt(`44`) +var numTwo = parseInt(`55`) +ansD.value = numOne + numTwo + +//write a function that returns a true if two var are truthy +//if both var are true, show "nope" +//if both var are false, also show "nope" +// if one is false and one is true, show "yep!" + +function truest(thingOne, thingTwo) { + if (thingOne && thingTwo === `true`){ + return `nope` + } else if (thingOne && thingTwo === `false`) { + return 'nope' + } else { + return 'yep!' + } +}; + +//write a function that only runs when both var are false +//if both var are false, show a confirmation message + +function womp(dumb, dumber) { + if (dumb && dumber === `false`) { + return `yes, they're both false` + } +}; From 4c37773d1c7eb5bf2e5534f2b2ce1b820da29a7f Mon Sep 17 00:00:00 2001 From: walzer85 Date: Thu, 5 Oct 2017 06:53:14 -0500 Subject: [PATCH 04/10] I think I got the date portion correct --- 01week/datatypes.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/01week/datatypes.js b/01week/datatypes.js index 6f4eeaccb..a738e8fe7 100644 --- a/01week/datatypes.js +++ b/01week/datatypes.js @@ -5,15 +5,15 @@ //make new var to store the today var and toDateString method //use var today with toTimeString method -var today = new date(dateString); -console.log(today); +var today = new date(); +var readable = console.log(today.toString()); //create a var to convert. //input a number into var convert //use convert and toString() method to make the number a string var num = 13 -var n = num.toString +var n = console.log(num.toString) //first method to convert string to number //input a string into parseInt() method and returns number @@ -22,21 +22,21 @@ var n = num.toString //use Number() method var str = `15 Years` -var int = parseInt(str) +var int = console.log(parseInt(str)) //tells what type of datatype your input is //create a variable of any main datatype //use the typeOf method on the variable var dataType = `words words words` -var result = typeOf(dataType) +var result = console.log(typeOf(dataType))) //make two variables that use parseInt() method //add the two variables with ansD. var numOne = parseInt(`44`) var numTwo = parseInt(`55`) -ansD.value = numOne + numTwo +ansD.value = console.log(numOne + numTwo) //write a function that returns a true if two var are truthy //if both var are true, show "nope" From e8443c7c1c08dc1d64ad8dee63cae9d0b4ccd647 Mon Sep 17 00:00:00 2001 From: walzer85 Date: Thu, 5 Oct 2017 18:17:19 -0500 Subject: [PATCH 05/10] worked out a few small syntax errors --- 01week/datatypes.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/01week/datatypes.js b/01week/datatypes.js index a738e8fe7..e9ad532aa 100644 --- a/01week/datatypes.js +++ b/01week/datatypes.js @@ -5,7 +5,7 @@ //make new var to store the today var and toDateString method //use var today with toTimeString method -var today = new date(); +var today = new Date(); var readable = console.log(today.toString()); //create a var to convert. @@ -29,14 +29,19 @@ var int = console.log(parseInt(str)) //use the typeOf method on the variable var dataType = `words words words` -var result = console.log(typeOf(dataType))) +var result = console.log(typeof(dataType))) -//make two variables that use parseInt() method -//add the two variables with ansD. +//Create two var that can be a string or number, the string must contain a number though +//Create a function with the two var +//Inside the function, add the two var together +//Use parseInt() to take the number out of the string -var numOne = parseInt(`44`) -var numTwo = parseInt(`55`) -ansD.value = console.log(numOne + numTwo) +var numOne = `13` +var numTwo = `17` + +function add (numOne, numTwo) { + return parseInt(numOne) + parseInt(numTwo) +} //write a function that returns a true if two var are truthy //if both var are true, show "nope" From 857b6e976e72ec6239e0ede131c0a018e844d259 Mon Sep 17 00:00:00 2001 From: walzer85 Date: Thu, 5 Oct 2017 18:34:04 -0500 Subject: [PATCH 06/10] consolidated comments --- 01week/datatypes.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/01week/datatypes.js b/01week/datatypes.js index e9ad532aa..0be254186 100644 --- a/01week/datatypes.js +++ b/01week/datatypes.js @@ -15,11 +15,8 @@ var readable = console.log(today.toString()); var num = 13 var n = console.log(num.toString) -//first method to convert string to number -//input a string into parseInt() method and returns number -//or... //set var to a string -//use Number() method +//use parseInt() method var str = `15 Years` var int = console.log(parseInt(str)) From 562bfecaab0049926e8ebe1e225003669a81b94b Mon Sep 17 00:00:00 2001 From: walzer85 Date: Thu, 5 Oct 2017 19:53:59 -0500 Subject: [PATCH 07/10] fixed one spacing error on line 39 --- 01week/datatypes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/01week/datatypes.js b/01week/datatypes.js index 0be254186..9d1e0f067 100644 --- a/01week/datatypes.js +++ b/01week/datatypes.js @@ -36,7 +36,7 @@ var result = console.log(typeof(dataType))) var numOne = `13` var numTwo = `17` -function add (numOne, numTwo) { +function add(numOne, numTwo) { return parseInt(numOne) + parseInt(numTwo) } From 2757db3ccd79ba37039c755001432aa9ca49527f Mon Sep 17 00:00:00 2001 From: walzer85 Date: Thu, 5 Oct 2017 20:32:49 -0500 Subject: [PATCH 08/10] completed rockpaperscissors --- 01week/datatypes.js | 2 +- 01week/rockPaperScissors.js | 23 +++++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/01week/datatypes.js b/01week/datatypes.js index 9d1e0f067..16e2e5d2f 100644 --- a/01week/datatypes.js +++ b/01week/datatypes.js @@ -26,7 +26,7 @@ var int = console.log(parseInt(str)) //use the typeOf method on the variable var dataType = `words words words` -var result = console.log(typeof(dataType))) +var result = console.log(typeof(dataType)) //Create two var that can be a string or number, the string must contain a number though //Create a function with the two var diff --git a/01week/rockPaperScissors.js b/01week/rockPaperScissors.js index 16f58790a..f32136227 100644 --- a/01week/rockPaperScissors.js +++ b/01week/rockPaperScissors.js @@ -9,10 +9,25 @@ const rl = readline.createInterface({ function rockPaperScissors(hand1, hand2) { - - // Write code here - -} + // check for a tie, if it is a tie, return tie, if not check for win + // rock beats scissors, scissors beats paper, paper beats rock + //to find who won, compare hand1 to 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 === 'rock') { + return 'Hand one wins!' + } else if (hand1 === 'paper' && hand2 === 'scissors') { + return 'Hand two wins!' + } else if (hand1 === 'scissors' && hand2 === 'rock') { + return 'Hand two wins!' + } else if (hand1 === 'scissors' && hand2 === 'paper') { + return 'Hand one wins!' + } +}; function getPrompt() { rl.question('hand1: ', (answer1) => { From 6f525be3ab97fbef7e23b4c48de60a429e9f4128 Mon Sep 17 00:00:00 2001 From: walzer85 Date: Sun, 8 Oct 2017 07:08:55 -0500 Subject: [PATCH 09/10] trying to fix issues with datatTypes assignment --- 01week/datatypes.js | 2 +- 01week/rockPaperScissors.js | 20 +++++++------------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/01week/datatypes.js b/01week/datatypes.js index 16e2e5d2f..846319d4d 100644 --- a/01week/datatypes.js +++ b/01week/datatypes.js @@ -6,7 +6,7 @@ //use var today with toTimeString method var today = new Date(); -var readable = console.log(today.toString()); +var readable = today.toString(); //create a var to convert. //input a number into var convert diff --git a/01week/rockPaperScissors.js b/01week/rockPaperScissors.js index f32136227..e7fd670a4 100644 --- a/01week/rockPaperScissors.js +++ b/01week/rockPaperScissors.js @@ -14,19 +14,13 @@ function rockPaperScissors(hand1, hand2) { //to find who won, compare hand1 to 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 === 'rock') { - return 'Hand one wins!' - } else if (hand1 === 'paper' && hand2 === 'scissors') { - return 'Hand two wins!' - } else if (hand1 === 'scissors' && hand2 === 'rock') { - return 'Hand two wins!' - } else if (hand1 === 'scissors' && hand2 === 'paper') { - return 'Hand one wins!' - } + } else if (hand1 === 'rock'){ + return hand2 === 'paper' ? 'Hand two wins!' : 'Hand one wins!'; + } else if (hand1 === 'paper') { + return hand2 === 'scissors' ? 'Hand two wins!' : 'Hand one wins!'; + } else if (hand1 === 'scissors') { + return hand2 === 'rock' ? 'Hand two wins!' : 'Hand one wins!'; + } }; function getPrompt() { From b696ddbb81f4d19748e4c5bc4306f38b38362254 Mon Sep 17 00:00:00 2001 From: walzer85 Date: Tue, 10 Oct 2017 20:00:07 -0500 Subject: [PATCH 10/10] defined variables to cut down run time --- 01week/datatypes.js | 35 +++++++++++++++++++++-------------- 01week/rockPaperScissors.js | 11 +++++++---- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/01week/datatypes.js b/01week/datatypes.js index 846319d4d..ef444cdd6 100644 --- a/01week/datatypes.js +++ b/01week/datatypes.js @@ -12,54 +12,61 @@ var readable = today.toString(); //input a number into var convert //use convert and toString() method to make the number a string -var num = 13 -var n = console.log(num.toString) +const num = 13 +const n = console.log(num.toString) //set var to a string //use parseInt() method -var str = `15 Years` -var int = console.log(parseInt(str)) +const str = `15 Years` +const int = console.log(parseInt(str)) //tells what type of datatype your input is //create a variable of any main datatype //use the typeOf method on the variable -var dataType = `words words words` -var result = console.log(typeof(dataType)) +const dataType = `words words words` +const result = console.log(typeof(dataType)) //Create two var that can be a string or number, the string must contain a number though //Create a function with the two var //Inside the function, add the two var together //Use parseInt() to take the number out of the string -var numOne = `13` -var numTwo = `17` +const numOne = `13` +const numTwo = `17` -function add(numOne, numTwo) { +function add() { return parseInt(numOne) + parseInt(numTwo) } +add(); + //write a function that returns a true if two var are truthy //if both var are true, show "nope" //if both var are false, also show "nope" // if one is false and one is true, show "yep!" function truest(thingOne, thingTwo) { - if (thingOne && thingTwo === `true`){ + if ((thingOne === true && thingTwo === true) || (thingOne === false && thingTwo === false)){ return `nope` - } else if (thingOne && thingTwo === `false`) { - return 'nope' } else { return 'yep!' } }; +truest(); + //write a function that only runs when both var are false //if both var are false, show a confirmation message -function womp(dumb, dumber) { - if (dumb && dumber === `false`) { +const dumb = dfs +const dumber = aadsadfdfds + +function womp() { + if (dumb === false && dumber === false) { return `yes, they're both false` } }; + +womp() diff --git a/01week/rockPaperScissors.js b/01week/rockPaperScissors.js index e7fd670a4..c4774d812 100644 --- a/01week/rockPaperScissors.js +++ b/01week/rockPaperScissors.js @@ -12,15 +12,18 @@ function rockPaperScissors(hand1, hand2) { // check for a tie, if it is a tie, return tie, if not check for win // rock beats scissors, scissors beats paper, paper beats rock //to find who won, compare hand1 to hand2 + const handOne = 'Hand one wins!' + const handTwo = 'Hand two wins!' + if(hand1 === hand2) { return "It's a tie!"; } else if (hand1 === 'rock'){ - return hand2 === 'paper' ? 'Hand two wins!' : 'Hand one wins!'; + return hand2 === 'paper' ? handTwo : handOne; } else if (hand1 === 'paper') { - return hand2 === 'scissors' ? 'Hand two wins!' : 'Hand one wins!'; + return hand2 === 'scissors' ? handTwo : handOne; } else if (hand1 === 'scissors') { - return hand2 === 'rock' ? 'Hand two wins!' : 'Hand one wins!'; - } + return hand2 === 'rock' ? handTwo : handOne; + } }; function getPrompt() {