From e5c79d1b1d7416b2e618374aa26e78647b2b2403 Mon Sep 17 00:00:00 2001 From: Sergio Otero Date: Sat, 11 Oct 2025 18:51:16 +0200 Subject: [PATCH 1/8] feat: iteration 1 completed --- .vscode/settings.json | 3 +++ index.js | 5 +++++ 2 files changed, 8 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..f673a71b7 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5502 +} \ No newline at end of file diff --git a/index.js b/index.js index 6b0fec3ad..a4c2bba14 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,9 @@ // Iteration 1: Names and Input +const hacker1 = "Sergio" +console.log(`The driver's name is ${hacker1}`); + +const hacker2 = "Carlos" +console.log(`The driver's name is ${hacker2}`); // Iteration 2: Conditionals From a120b5b1e64fe02696b6029594c2bdaf27cc7850 Mon Sep 17 00:00:00 2001 From: Sergio Otero Date: Sat, 11 Oct 2025 18:56:34 +0200 Subject: [PATCH 2/8] feat: iteration 2 completed --- index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index a4c2bba14..128fec0c7 100644 --- a/index.js +++ b/index.js @@ -3,10 +3,16 @@ const hacker1 = "Sergio" console.log(`The driver's name is ${hacker1}`); const hacker2 = "Carlos" -console.log(`The driver's name is ${hacker2}`); +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 (hacker1.length < hacker2.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, ${hacker2.length} characters`); +} // Iteration 3: Loops From 659aacbd4e0320bb1fb3c42beac97c992934fe1f Mon Sep 17 00:00:00 2001 From: Sergio Otero Date: Sat, 11 Oct 2025 19:14:22 +0200 Subject: [PATCH 3/8] feat: iteration 3 completed --- index.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/index.js b/index.js index 128fec0c7..f11854355 100644 --- a/index.js +++ b/index.js @@ -16,3 +16,27 @@ if (hacker1.length > hacker2.length) { } // Iteration 3: Loops +let name = ""; +for (let i = 0; i < hacker1.length; i++) { + const char = hacker1[i]; + name += char.toUpperCase() + " "; +} +console.log(name); + +let navigator = ""; +for (let i = hacker2.length - 1; i >= 0; i--) { + const char = hacker2[i]; + navigator += char; +} +console.log(navigator); + + +const names = [hacker1, hacker2]; +names.sort(); +if (names[0] === "Sergio") { + console.log(`The driver's name goes first`); +} else if (names[0] === "Carlos") { + console.log(`Yo, the navigator goes first, definetely`); +} else { + console.log(`What?! You both have the same name?`); +} From 99032ab09bf2fb4a3ee57ce0ab4f7641266a374f Mon Sep 17 00:00:00 2001 From: Sergio Otero Date: Sat, 11 Oct 2025 19:37:24 +0200 Subject: [PATCH 4/8] feat: iteration bonus 1 completed --- index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/index.js b/index.js index f11854355..275955011 100644 --- a/index.js +++ b/index.js @@ -40,3 +40,15 @@ if (names[0] === "Sergio") { } else { console.log(`What?! You both have the same name?`); } + + +//Bonus 1 +const text = ` +Lorem ipsum dolor sit amet, consectetur adipiscing elit. In at augue at urna commodo pellentesque nec at libero. Vestibulum quis augue sollicitudin, luctus ipsum in, efficitur justo. Vestibulum enim leo, viverra in aliquet ac, lobortis nec quam. Proin at felis eleifend, gravida orci et, finibus lorem. Cras consequat lorem in orci gravida lobortis. Pellentesque ac lectus quis ipsum posuere pharetra non id dolor. Mauris in gravida ante. Fusce condimentum iaculis nulla ac aliquet. Integer sed dolor non quam tristique blandit et ut metus. Mauris diam justo, semper vel pharetra vel, viverra ut erat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vestibulum lobortis posuere arcu, id blandit nisi vulputate sit amet. Donec placerat porta ligula. Morbi volutpat a dui ac cursus. + +Vivamus non nulla eu ipsum ullamcorper feugiat. Proin varius congue libero a vehicula. Donec interdum bibendum erat, at sagittis velit tincidunt vitae. Mauris posuere vel ipsum in elementum. Integer non purus nulla. Maecenas euismod faucibus finibus. Sed enim quam, tempus at placerat sit amet, ullamcorper id ipsum. Curabitur metus eros, viverra sed venenatis ac, sollicitudin sit amet mi. Nunc vel felis nisi. Cras leo neque, egestas sit amet nisl in, venenatis varius dui. Suspendisse ac tincidunt quam, id iaculis elit. Fusce convallis quis augue sed suscipit. Nam condimentum odio ac tortor posuere cursus. Nam nunc mi, congue id sapien et, rhoncus sagittis massa. + +Aliquam maximus arcu quam, id aliquam ante pharetra a. Nam posuere laoreet justo a ornare. Suspendisse porttitor mollis neque. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nullam rhoncus turpis orci, ac pulvinar nibh tempus at. Nam dapibus at elit et imperdiet. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Sed a nulla arcu. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis convallis blandit lorem a luctus. Pellentesque malesuada porttitor lectus, eget ultricies ligula dictum vitae. +`; +const words = text.split(" "); +console.log(words.length); From 779df9fb470c56ed70a3e6d3411de8249be1e042 Mon Sep 17 00:00:00 2001 From: Sergio Otero Date: Sat, 11 Oct 2025 20:09:20 +0200 Subject: [PATCH 5/8] feat: iteration bonus 2 completed --- index.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/index.js b/index.js index 275955011..fce5d3736 100644 --- a/index.js +++ b/index.js @@ -52,3 +52,21 @@ Aliquam maximus arcu quam, id aliquam ante pharetra a. Nam posuere laoreet justo `; const words = text.split(" "); console.log(words.length); + + +//Bonus 2 +const phraseToCheck = "stack cats"; + +let sentence = phraseToCheck.replace(/[^a-zA-Z]/g, ""); +let sentenceReversed = ""; + +for (let i = 0; i < sentence.length; i++){ + const char = sentence[i]; + sentenceReversed += char; +} + +if(sentence === sentenceReversed) { + console.log("It's a palindrome"); +} else { + console.log("It's not a palindrome"); +} \ No newline at end of file From 9697079f8d3448b8ba3a4cba965538982d2c3ec4 Mon Sep 17 00:00:00 2001 From: Sergio Otero Date: Sat, 11 Oct 2025 20:16:52 +0200 Subject: [PATCH 6/8] fix: there was some code missing in bonus 1 --- index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/index.js b/index.js index fce5d3736..936c68256 100644 --- a/index.js +++ b/index.js @@ -53,6 +53,17 @@ Aliquam maximus arcu quam, id aliquam ante pharetra a. Nam posuere laoreet justo const words = text.split(" "); console.log(words.length); +let counter = 0; + +for (let i = 0; i < words.length; i++) { + const word = words[i]; + if(word == "et"){ + counter++; + } +} + +console.log("Number of 'et': ",counter); + //Bonus 2 const phraseToCheck = "stack cats"; From 26b17104bd8c4e8a672f8838d5451db4c91d9691 Mon Sep 17 00:00:00 2001 From: Sergio Otero Date: Sat, 11 Oct 2025 20:22:00 +0200 Subject: [PATCH 7/8] fix: bug fixed in Bonus 2 --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 936c68256..a0a3e2f0b 100644 --- a/index.js +++ b/index.js @@ -71,7 +71,7 @@ const phraseToCheck = "stack cats"; let sentence = phraseToCheck.replace(/[^a-zA-Z]/g, ""); let sentenceReversed = ""; -for (let i = 0; i < sentence.length; i++){ +for (let i = sentence.length - 1; i > 0; i--){ const char = sentence[i]; sentenceReversed += char; } From 3a245a892f219c4ee37634a63d20c0206dafe815 Mon Sep 17 00:00:00 2001 From: Sergio Otero Date: Sat, 11 Oct 2025 20:25:16 +0200 Subject: [PATCH 8/8] fix: typo errors corrected --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index a0a3e2f0b..9ac745c56 100644 --- a/index.js +++ b/index.js @@ -36,7 +36,7 @@ names.sort(); if (names[0] === "Sergio") { console.log(`The driver's name goes first`); } else if (names[0] === "Carlos") { - console.log(`Yo, the navigator goes first, definetely`); + console.log(`Yo, the navigator goes first, definitely`); } else { console.log(`What?! You both have the same name?`); } @@ -57,7 +57,7 @@ let counter = 0; for (let i = 0; i < words.length; i++) { const word = words[i]; - if(word == "et"){ + if(word === "et"){ counter++; } } @@ -71,7 +71,7 @@ const phraseToCheck = "stack cats"; let sentence = phraseToCheck.replace(/[^a-zA-Z]/g, ""); let sentenceReversed = ""; -for (let i = sentence.length - 1; i > 0; i--){ +for (let i = sentence.length - 1; i >= 0; i--){ const char = sentence[i]; sentenceReversed += char; }