diff --git a/01week/Conditionals.js b/01week/Conditionals.js new file mode 100644 index 000000000..4907dd833 --- /dev/null +++ b/01week/Conditionals.js @@ -0,0 +1,41 @@ +console.log("start program"); + +//write a fuction that takes in 3 variable +//and checks if they are all strings + + +function areStrings(thing1, thing2, thing3){ + // code to excute my logic + console.log("thing1 =", thing1); + console.log("thing2 =", thing2); + console.log("thing3 =", thing3); + + let type1 = typeof thing1; + let type2 = typeof thing2; + let type3 = typeof thing3; + + //if all 3 type are strings then print out "They are all strings" + if( + type1 === "string" && + type2 === "string" && + type3 === "string" + ){ + console.log("they are not all string"); + } + else{ + console.log("they are not all string"); + } +} + +areStrings( 4, "Lance", null) +console.log("end program"); + + +function isPassing(grade){ + if(grade >= 70){ + return true; + } + else{ + return false; + } +} \ No newline at end of file diff --git a/01week/datatypes.js b/01week/datatypes.js index e69de29bb..34e33eee1 100644 --- a/01week/datatypes.js +++ b/01week/datatypes.js @@ -0,0 +1,21 @@ +'use strict' + +//Write a JavaScript program to display the current day and time. +let now = Date(); +console.log("the current date and time", now); + +//Write a JavaScript program to convert a number to a string. +const theNumber = 5; +const theString = theNumber.toString(); + +console.log("The type of theSring varaible is", (typeof theString)) +console.log("The type of theNumber varaible is", (typeof theNumber)) +console.log("The syring is"); +console.log("The number is", theNumber); + + +//Write a JavaScript program to convert a string to the number. +const theOtherString = "11"; +const theOtherNumber = (theOtherString, 10); +console.log("The otherString type is", (typeof theOtherString)); +console.log("The otherNumber type is", (typeof theOtherNumber)); \ No newline at end of file diff --git a/01week/rockPaperScissors.js b/01week/rockPaperScissors.js index 72f0f1a89..eef831196 100644 --- a/01week/rockPaperScissors.js +++ b/01week/rockPaperScissors.js @@ -13,12 +13,29 @@ const rl = readline.createInterface({ // the function that will be called by the unit test below const rockPaperScissors = (hand1, hand2) => { - + hand1 = hand1.toLowerCase() + hand2 = hand2.toLowerCase() + console.log(hand1) // Write code here // Use the unit test to see what is expected + if (hand1 === hand2){ + return "It's a tie!"; + } + + else if (hand1 === "rock" && hand2 === "paper"){ + if (hand1 === "paper" && hand2 === "scissors"); + else (hand1 === "scissors" && hand2 === "rock"); + return "Hand two wins!"; + } + else if (hand1 === "paper" && hand2 === "rock"){ + if (hand1 === "rock" && hand2 === "scissors"); + else (hand1 === "scissors" && hand2 === "paper"); + return "Hand one wins!"; + }; } + // the first function called in the program to get an input from the user // to run the function use the command: node main.js // to close it ctrl + C