From 9542298b81c9b893d46a317395020359a40a85e0 Mon Sep 17 00:00:00 2001 From: Ben Balderas Date: Fri, 7 Feb 2020 18:05:56 -0600 Subject: [PATCH 1/5] Iteration 1 Done --- js/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/js/index.js b/js/index.js index dd8ff0062..d66dd8b16 100644 --- a/js/index.js +++ b/js/index.js @@ -1,5 +1,9 @@ // Iteration 1: Names and Input +let hacker1 = 'Goku' +console.log(`The driver's name is ${hacker1}`) +let hacker2 = 'Vegeta' +console.log(`The navigator's name is ${hacker2}`) // Iteration 2: Conditionals From d9395927b4daaad458d6920ecf606e9c75c41020 Mon Sep 17 00:00:00 2001 From: Ben Balderas Date: Fri, 7 Feb 2020 18:19:33 -0600 Subject: [PATCH 2/5] Iteration 2 Done --- js/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/js/index.js b/js/index.js index d66dd8b16..b1baa29fd 100644 --- a/js/index.js +++ b/js/index.js @@ -6,6 +6,15 @@ let hacker2 = 'Vegeta' console.log(`The navigator's name is ${hacker2}`) // Iteration 2: Conditionals +let hacker1Length = hacker1.length +let hacker2Length = hacker2.length +if(hacker1Length > hacker2Length) { + console.log(`The driver has the longer name, it has ${hacker1Length} characters`) +} else if(hacker1Length === hacker2Length) { + console.log(`Wow, you both have equally long names, ${hacker1Length} characters!`) +} else { + console.log(`It seems that the navigator has the longest name, it has ${hacker2Length} characters.`) +} // Iteration 3: Loops \ No newline at end of file From 2bad6fee2046c714b14bd3ed5ffe29e912784acc Mon Sep 17 00:00:00 2001 From: Ben Balderas Date: Fri, 7 Feb 2020 18:51:14 -0600 Subject: [PATCH 3/5] Iteration 3 Done --- js/index.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/js/index.js b/js/index.js index b1baa29fd..a13812018 100644 --- a/js/index.js +++ b/js/index.js @@ -17,4 +17,26 @@ if(hacker1Length > hacker2Length) { console.log(`It seems that the navigator has the longest name, it has ${hacker2Length} characters.`) } -// Iteration 3: Loops \ No newline at end of file +// Iteration 3: Loops +let hacker1Spaced = "" +let hacker2Backward = "" + +for (const char of hacker1) { + hacker1Spaced = hacker1Spaced + char.toUpperCase() + " " +} + +console.log(hacker1Spaced) + +for (const char of hacker2.split("").reverse()) { + hacker2Backward += char +} + +console.log(hacker2Backward) + +if (hacker1.localeCompare(hacker2) === 1) { + console.log("The driver's name goes first.") +} else if (hacker1.localeCompare(hacker2) === -1) { + console.log("Yo, the navigator goes first definitely.") +} else { + console.log("What?! You both have the same name?") +} \ No newline at end of file From 952ce5a9a8a9b70003decd9963ec76819af95b6c Mon Sep 17 00:00:00 2001 From: Ben Balderas Date: Fri, 7 Feb 2020 19:01:43 -0600 Subject: [PATCH 4/5] Bonus 1 Done --- js/index.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/js/index.js b/js/index.js index a13812018..a70183ab1 100644 --- a/js/index.js +++ b/js/index.js @@ -39,4 +39,19 @@ if (hacker1.localeCompare(hacker2) === 1) { console.log("Yo, the navigator goes first definitely.") } else { console.log("What?! You both have the same name?") -} \ No newline at end of file +} + +//Bonus 1 +let someText = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam egestas leo turpis, vel venenatis diam blandit vel. Pellentesque eu diam quis nisl eleifend imperdiet nec sed nisl. Sed mauris augue, lacinia sed eleifend eget, sodales ut erat. Nunc neque nulla, sodales ac suscipit posuere, fermentum at arcu. Pellentesque porta vehicula lacus et posuere. Proin metus urna, egestas in finibus in, hendrerit eget magna. Fusce hendrerit diam sit amet ex blandit, eu malesuada neque dapibus. + +Sed a sodales tellus. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vivamus rhoncus quam a dui efficitur luctus. Donec ut justo ut erat faucibus venenatis et fermentum sapien. Pellentesque imperdiet leo nec luctus interdum. Quisque efficitur, risus in pellentesque pellentesque, libero odio elementum massa, et ultricies massa massa consectetur orci. Donec non sagittis augue. Pellentesque blandit, ligula id placerat vehicula, enim purus pharetra augue, sit amet mollis est nibh vitae diam. Donec arcu enim, consequat eget lectus ac, porta eleifend diam. Suspendisse tristique vitae eros nec luctus. Aenean suscipit, erat condimentum sodales commodo, eros velit pulvinar augue, et fringilla nisi mi vitae velit. Nunc sed molestie est. Aenean eu leo lectus. Phasellus interdum elit nec vestibulum convallis. Quisque gravida massa quis sapien pulvinar egestas. Etiam urna odio, pharetra eu elementum nec, accumsan eget mauris. + +Etiam ipsum eros, suscipit sit amet nulla eu, commodo gravida ipsum. Cras vel consectetur felis. Quisque suscipit nibh non ipsum rutrum convallis. Vivamus vitae suscipit mauris. Nullam lorem ante, posuere quis ligula eget, commodo ornare neque. Aliquam condimentum, ante nec rutrum ultricies, ipsum arcu luctus leo, eget viverra eros velit non lacus. Aenean massa lectus, euismod non risus at, aliquet feugiat sapien. Praesent blandit leo a nisi consectetur, a imperdiet neque tristique. Curabitur blandit interdum convallis. Nullam vehicula elit a consectetur euismod.` + +let numOfWords = someText.split(" ").length; + +for (let i = 0; i <= numOfWords; i++) { + console.log(i); +} + +console.log(`The text has ${numOfWords} words`) \ No newline at end of file From 2873f0524594b1f40966f2a35338cf83b9bb8e1f Mon Sep 17 00:00:00 2001 From: Ben Balderas Date: Fri, 7 Feb 2020 19:41:03 -0600 Subject: [PATCH 5/5] All done --- js/index.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/js/index.js b/js/index.js index a70183ab1..a29dfd5c0 100644 --- a/js/index.js +++ b/js/index.js @@ -54,4 +54,15 @@ for (let i = 0; i <= numOfWords; i++) { console.log(i); } -console.log(`The text has ${numOfWords} words`) \ No newline at end of file +console.log(`The text has ${numOfWords} words`) + +//Bonus 2 +let phraseToCheck = "Was it a car or a cat I saw?" +let phraseForward = phraseToCheck.replace(/[^a-zA-Z]+/g, "").toUpperCase() +let phraseBackward = phraseToCheck.replace(/[^a-zA-Z]+/g, "").toUpperCase().split("").reverse().join("") + +if (phraseForward == phraseBackward) { + console.log(`The phrase: \"${phraseToCheck}\" is a pallindrome`) +} else { + console.log(`The phrase: \"${phraseToCheck}\" is a NOT pallindrome`) +} \ No newline at end of file