From 5cdc90dae84c2db27e4c7516b2a75c73661a131b Mon Sep 17 00:00:00 2001 From: Kilian Date: Fri, 20 Mar 2026 16:18:34 +0000 Subject: [PATCH 1/5] 1 iteration --- index.html | 30 +++++++++++++++++++++--------- index.js | 6 ++++-- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index 0758034e6..f971ba576 100644 --- a/index.html +++ b/index.html @@ -1,16 +1,28 @@ - + - - - + + + LAB | JS Basic Algorithms - - + + +

LAB | JS Basic Algorithms



-

Open the Dev Tools console to see the console output.

+

+ Open the + Dev Tools console + to see the console output. +

- - \ No newline at end of file + + diff --git a/index.js b/index.js index 6b0fec3ad..ac854f3f3 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,9 @@ // Iteration 1: Names and Input +let hacker1 = 'John'; +let hacker2 = 'Kilian'; - +console.log(`The driver's is ${hacker1} +The navegator's name is ${hacker2}`); // Iteration 2: Conditionals - // Iteration 3: Loops From ebeab40e0854eb1e66d31e3a985bf4f700f7cef9 Mon Sep 17 00:00:00 2001 From: Kilian Date: Fri, 20 Mar 2026 17:12:49 +0000 Subject: [PATCH 2/5] iter 2 --- index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.js b/index.js index ac854f3f3..bd19340fb 100644 --- a/index.js +++ b/index.js @@ -5,5 +5,8 @@ let hacker2 = 'Kilian'; console.log(`The driver's is ${hacker1} The navegator's name is ${hacker2}`); // Iteration 2: Conditionals +if (hacker1.length == hacker2.length) console.log(`Wow, you both have equally long names, ${hacker1.length} characters!`) +else if(hacker1.length > hacker2.length) console.log(`The driver has the longest name, it has ${hacker1.length} characters.`) +else console.log(`It seems that the navigator has the longest name, it has ${hacker2.length} characters.`) // Iteration 3: Loops From e62e5cd3c1ef25db3bd1be1aa4cded8790eb9734 Mon Sep 17 00:00:00 2001 From: Kilian Date: Fri, 20 Mar 2026 17:13:10 +0000 Subject: [PATCH 3/5] ite 3.1, 3.2 --- index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/index.js b/index.js index bd19340fb..dbdd9cafa 100644 --- a/index.js +++ b/index.js @@ -10,3 +10,13 @@ else if(hacker1.length > hacker2.length) console.log(`The driver has the longest else console.log(`It seems that the navigator has the longest name, it has ${hacker2.length} characters.`) // Iteration 3: Loops +let nameUpper = "" +for (let i = 0; i < hacker1.length; i++){ + nameUpper += hacker1[i].toUpperCase() + " " +} +console.log(nameUpper) +nameUpper = "" +for(i = hacker1.length - 1; i >= 0; i--){ + nameUpper += hacker1[i]; +} +console.log(nameUpper) \ No newline at end of file From 35d97bda95d61e318502f0446ab8e9a4cc3b39cb Mon Sep 17 00:00:00 2001 From: Kilian Date: Fri, 20 Mar 2026 17:29:40 +0000 Subject: [PATCH 4/5] ite 3.3 and fix with .toLowerCase() --- index.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index dbdd9cafa..7953ae8ee 100644 --- a/index.js +++ b/index.js @@ -10,13 +10,23 @@ else if(hacker1.length > hacker2.length) console.log(`The driver has the longest else console.log(`It seems that the navigator has the longest name, it has ${hacker2.length} characters.`) // Iteration 3: Loops +//Iteration 3.1 let nameUpper = "" for (let i = 0; i < hacker1.length; i++){ nameUpper += hacker1[i].toUpperCase() + " " } console.log(nameUpper) +//iteration 3.2 nameUpper = "" -for(i = hacker1.length - 1; i >= 0; i--){ - nameUpper += hacker1[i]; +for(i = hacker2.length - 1; i >= 0; i--){ + nameUpper += hacker2[i]; +} +console.log(nameUpper) +//Iteration 3.3 +if (hacker1.toLowerCase() == hacker2.toLowerCase()) { + console.log("What?! You both have the same name?") +} else if (hacker1.toLowerCase() < hacker2.toLowerCase()) { + console.log("The driver's name goes first."); +}else{ + console.log("Yo, the navigator goes first, definitely."); } -console.log(nameUpper) \ No newline at end of file From 37b63b189dda22bc2772754ca6abb6cc047b48d3 Mon Sep 17 00:00:00 2001 From: Kilian Date: Fri, 20 Mar 2026 18:02:08 +0000 Subject: [PATCH 5/5] Bonus 2 Palindromo --- index.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/index.js b/index.js index 7953ae8ee..4274a78e2 100644 --- a/index.js +++ b/index.js @@ -30,3 +30,17 @@ if (hacker1.toLowerCase() == hacker2.toLowerCase()) { }else{ console.log("Yo, the navigator goes first, definitely."); } + +// Bonus 2 + +let isPalindromo = true; +const isWord = "racecar"; +for(let i = 0, j = isWord.length - 1; i < j; i++, j--) { + if (isWord[i] == isWord[j]) { + continue; + } else { + isPalindromo = false; + break + } +} +console.log(isPalindromo ? "Es un palĂ­ndromo" : "No es un palĂ­ndromo") \ No newline at end of file