From c99ab2b13c7aeb1de2466350e5caaeda83b72964 Mon Sep 17 00:00:00 2001 From: Manal Malik Date: Mon, 7 Sep 2026 18:04:14 +0200 Subject: [PATCH] Attempted basic algo lab --- index.js | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 6b0fec3ad..9af72667d 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,35 @@ // Iteration 1: Names and Input - +const hacker1 = "Manal"; +console.log("The driver's name is", hacker1); +const hacker2 = "Bob"; +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 +console.log(hacker1.split("").join(" ").toUpperCase()); +console.log(hacker2.split("").reverse().join("")); + +const driver = hacker1.toLowerCase(); +const navigator = hacker2.toLowerCase(); + +if (driver === navigator) { + console.log("What?! You both have the same name?"); +} else if (driver < navigator) { + console.log("Yo, the navigator goes first, definitely."); +} else { + console.log("The driver's name goes first."); +}