From 475f4e2695bea02f4ed0876c541fbcb959dcae42 Mon Sep 17 00:00:00 2001 From: 250300G <250300g@gmail.com> Date: Thu, 2 Apr 2026 08:47:38 +0200 Subject: [PATCH 1/2] 3-lab-javascript-basic-algorithms --- index.html | 2 ++ index.js | 26 ++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 0758034e6..5333905ff 100644 --- a/index.html +++ b/index.html @@ -12,5 +12,7 @@

LAB | JS Basic Algorithms

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..ebe825a41 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,29 @@ // Iteration 1: Names and Input -// Iteration 2: Conditionals + let hacker1 = "john"; + let hacker2 = "paul"; + + console.log(`The hacker's name is ${hacker1}`); + console.log(`The navigator's name is ${hacker2}`); + + // Iteratio n 2 +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(`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 + +function hacker1toUpperCase(str) { + const result = str.toUppercase().split('').join(' '); + console.log(result); + + +}// REVERSE -// Iteration 3: Loops From 9f380379fda0d2771ac7000d91a1c9c324e94213 Mon Sep 17 00:00:00 2001 From: 250300G <250300g@gmail.com> Date: Mon, 27 Apr 2026 20:22:19 +0200 Subject: [PATCH 2/2] uu --- index.js | 70 ++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 25 deletions(-) diff --git a/index.js b/index.js index ebe825a41..52afbe8d8 100644 --- a/index.js +++ b/index.js @@ -1,29 +1,49 @@ // Iteration 1: Names and Input - - - let hacker1 = "john"; - let hacker2 = "paul"; - - console.log(`The hacker's name is ${hacker1}`); - console.log(`The navigator's name is ${hacker2}`); - - - // Iteratio n 2 -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(`The navigator has the longest name, it has ${hacker2.length} characters`); +let name1 = "hacker1"; +console.log(`Drivers'name is ${name1}`); + +let name2 = "hacker2"; +console.log(`navigator's name is ${name2}`); + + + +// Iteration 2: Conditionals + +if (name1.length > name2.length) { + console.log(`It seems the driver has the longest ${name1}, it has ${name1.length} characters`); + } +else if (name1.length < name2.length) { + console.log(`It seems the Navigator has the longest ${name2}, it has ${name2.length} characters`); + } +else {(console.log(`Wow, you both have equally long names, ${name1.length} characters`))}; + + + +// Iteration 3: Loops +console.log(name1.toUpperCase()); + +console.log(name1.split('').join('')); + + function reverseName (name2) { + return name2.split('').reverse().join(''); +} +console.log(reverseName(name2)); + + + if (name1.charAt(0) > name2.charAt(0) ) { + console.log(`${name1} goes first`);} + + else if (name1.charAt(0) < name2.charAt(0) ) { + console.log(`Yo, ${name2} goes first, definitely`);} + +else console.log("What?! You both have the same name?"); + +//Bonus 1: +let longText ="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiueu fugiat nulla pariatur. Excepteur sint ocim id est laborum."; +for (i=0 ; i <= longText.length; i++) { +let text = longText.split(""); +console.log(text.length); } -else - console.log(`Wow, you both have equally long names, ${hacker1.length} characters!`) - -// Iteration 3 - -function hacker1toUpperCase(str) { - const result = str.toUppercase().split('').join(' '); - console.log(result); - -}// REVERSE +// REVERSE