From 806e975b23eaba53869f0c053a8c1f4a755ea761 Mon Sep 17 00:00:00 2001 From: Carlos Mateo Date: Thu, 7 Nov 2019 10:16:19 +0100 Subject: [PATCH 1/6] Adds gitignore file --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..496ee2ca6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store \ No newline at end of file From b5ca1c2e23f5005a8079f7388dc9d0450dd6af5c Mon Sep 17 00:00:00 2001 From: Carlos Mateo Date: Thu, 7 Nov 2019 10:20:06 +0100 Subject: [PATCH 2/6] Iteration 1 completed --- js/index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/js/index.js b/js/index.js index dd8ff0062..83d37abb4 100644 --- a/js/index.js +++ b/js/index.js @@ -1,5 +1,12 @@ // Iteration 1: Names and Input +let hacker1 = "Pedro Méndez"; + +console.log(`The driver's name is ${hacker1}`); + +let hacker2 = "Carlos Mateo"; + +console.log(`The navigator's name is ${hacker2}`); // Iteration 2: Conditionals From 368cfeaf64b73a96c40c4734572cd6361b89d5df Mon Sep 17 00:00:00 2001 From: Carlos Mateo Date: Thu, 7 Nov 2019 14:14:58 +0100 Subject: [PATCH 3/6] Iteration 2 completed --- js/index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/js/index.js b/js/index.js index 83d37abb4..3c8068854 100644 --- a/js/index.js +++ b/js/index.js @@ -10,5 +10,12 @@ console.log(`The navigator's name is ${hacker2}`); // Iteration 2: Conditionals +if (hacker1.length > hacker2.length) { + console.log(`The driver has the longest name, it has ${hacker1.length} characters.`); +} else if (hacker2.length > hacker1.length) { + console.log(`It seems that the navigator has the longest name, it has ${hacker2.length} characters.`); +} else { + console.log(`Wow, you both have equally long names, ${hacker1.length} characters!`); +} // Iteration 3: Loops \ No newline at end of file From 05807ea8d6c8cbfc09bfc182ba0b5c6d6f659d1c Mon Sep 17 00:00:00 2001 From: Carlos Mateo Date: Thu, 7 Nov 2019 17:34:54 +0100 Subject: [PATCH 4/6] Iteration 3 completed + Adds extra comments per drill --- js/index.js | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/js/index.js b/js/index.js index 3c8068854..ee1c9a7a6 100644 --- a/js/index.js +++ b/js/index.js @@ -1,15 +1,16 @@ // Iteration 1: Names and Input - +// 1.1 let hacker1 = "Pedro Méndez"; - +// 1.2 console.log(`The driver's name is ${hacker1}`); - +// 1.3 let hacker2 = "Carlos Mateo"; - +// 1.4 console.log(`The navigator's name is ${hacker2}`); -// Iteration 2: Conditionals +// Iteration 2: Conditionals +// 2.1 if (hacker1.length > hacker2.length) { console.log(`The driver has the longest name, it has ${hacker1.length} characters.`); } else if (hacker2.length > hacker1.length) { @@ -18,4 +19,21 @@ if (hacker1.length > hacker2.length) { console.log(`Wow, you both have equally long names, ${hacker1.length} characters!`); } -// Iteration 3: Loops \ No newline at end of file + +// Iteration 3: Loops +if (hacker1) { + // 3.1 + console.log(hacker1.toUpperCase().split('').join(' ')); + + // 3.2 + console.log(hacker1.split('').reverse().join('')); +} + +// 3.3 +if (hacker1.charAt(0) < hacker2.charAt(0)) { + console.log(`The driver's name goes first.`); +} else if (hacker2.charAt(0) < hacker1.charAt(0)) { + 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 e2bde2a5740375a4262bf3242da1777713b15eb0 Mon Sep 17 00:00:00 2001 From: Carlos Mateo Date: Thu, 7 Nov 2019 21:51:04 +0100 Subject: [PATCH 5/6] Bonus 1 completed --- js/index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/js/index.js b/js/index.js index ee1c9a7a6..80b8da692 100644 --- a/js/index.js +++ b/js/index.js @@ -36,4 +36,14 @@ if (hacker1.charAt(0) < hacker2.charAt(0)) { 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 paragraphs = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi porta erat a urna consequat scelerisque. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Mauris egestas elit vitae vulputate venenatis. Cras iaculis lorem quam, eget rutrum mauris pulvinar eget. Nam interdum dictum dui in pellentesque. Proin eget metus lorem. Donec pretium euismod cursus. Suspendisse gravida sollicitudin risus sit amet condimentum. Sed egestas pharetra laoreet. + +Morbi in velit mattis, eleifend lectus ornare, convallis libero. Etiam metus nibh, consectetur ut ex eget, porttitor laoreet nibh. Nunc sodales, elit nec aliquet viverra, velit eros varius lectus, at porttitor nisi ligula ut ex. Mauris et orci scelerisque, vehicula dolor sit amet, tincidunt justo. Vivamus dapibus turpis et ipsum semper, sed ultricies sapien fringilla. Curabitur et blandit ligula. Maecenas quis venenatis nisl, sit amet dignissim velit. + +Nunc gravida lectus ligula, ac iaculis nulla gravida in. Pellentesque pulvinar, metus a varius consequat, nunc erat rutrum lacus, vitae egestas velit tellus non nisl. Nullam scelerisque tincidunt urna sit amet feugiat. Curabitur sodales justo sed erat vulputate iaculis. Mauris a lacus in purus vehicula efficitur quis eget metus. Donec rhoncus a erat id dapibus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse non placerat nunc.`; + +paragraphs.replace(/\n+/g, ' ').split(' ').length; \ No newline at end of file From 174f085dc000e02d15f162c9b72db3c4d10e5ed1 Mon Sep 17 00:00:00 2001 From: Carlos Mateo Date: Thu, 7 Nov 2019 22:43:24 +0100 Subject: [PATCH 6/6] Bonus 2 completed --- js/index.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/js/index.js b/js/index.js index 80b8da692..d92d93c6f 100644 --- a/js/index.js +++ b/js/index.js @@ -46,4 +46,17 @@ Morbi in velit mattis, eleifend lectus ornare, convallis libero. Etiam metus nib Nunc gravida lectus ligula, ac iaculis nulla gravida in. Pellentesque pulvinar, metus a varius consequat, nunc erat rutrum lacus, vitae egestas velit tellus non nisl. Nullam scelerisque tincidunt urna sit amet feugiat. Curabitur sodales justo sed erat vulputate iaculis. Mauris a lacus in purus vehicula efficitur quis eget metus. Donec rhoncus a erat id dapibus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse non placerat nunc.`; -paragraphs.replace(/\n+/g, ' ').split(' ').length; \ No newline at end of file +paragraphs.replace(/\n+/g, ' ').split(' ').length; + + +// Bonus 2: +let userInput = prompt(`Please enter a sentence. I'll verify where it's a palindrome or not 😎`); + +let sentence = userInput.toLowerCase().replace(/\W/g, ''); +let reversedSentence = sentence.split('').reverse().join(''); + +if (sentence === reversedSentence) { + console.log(`${userInput} - it's a palindrome! ✅`) +} else { + console.log(`${userInput} - it's not a palindrome! 🙅🏻‍♂️`) +} \ No newline at end of file