diff --git a/01week/datatypes.js b/01week/datatypes.js index e69de29bb..ef444cdd6 100644 --- a/01week/datatypes.js +++ b/01week/datatypes.js @@ -0,0 +1,72 @@ +`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(); +var readable = today.toString(); + +//create a var to convert. +//input a number into var convert +//use convert and toString() method to make the number a string + +const num = 13 +const n = console.log(num.toString) + +//set var to a string +//use parseInt() method + +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 + +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 + +const numOne = `13` +const numTwo = `17` + +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 === true && thingTwo === true) || (thingOne === false && 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 + +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 16f58790a..c4774d812 100644 --- a/01week/rockPaperScissors.js +++ b/01week/rockPaperScissors.js @@ -9,10 +9,22 @@ 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 + 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' ? handTwo : handOne; + } else if (hand1 === 'paper') { + return hand2 === 'scissors' ? handTwo : handOne; + } else if (hand1 === 'scissors') { + return hand2 === 'rock' ? handTwo : handOne; + } +}; function getPrompt() { rl.question('hand1: ', (answer1) => { diff --git a/index.html b/index.html index a8de93e90..ffe101bd4 100644 --- a/index.html +++ b/index.html @@ -5,6 +5,6 @@