From 2bc4207307fc6a00cb93d7ffbdd1b493077e678c Mon Sep 17 00:00:00 2001 From: Pamela Palacios Date: Tue, 17 Jun 2025 12:27:12 +0200 Subject: [PATCH] mensaje --- index.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 6b0fec3ad..88d2c5bcd 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,26 @@ // Iteration 1: Names and Input - +let hacker1 = prompt("What is your name?"); +alert("The driver's name is " + hacker1); +let hacker2 = navigator.userAgent; +alert("The navigator's name is " + hacker2); // Iteration 2: Conditionals +if (hacker1.length > hacker2.length) { + alert("The driver has the longest name, it has " + hacker1.length + " characters."); +} else if (hacker1.length < hacker2.length) { + alert("It seems that the navigator has the longest name, it has " + hacker2.length + " characters."); +} else {hacker1.length === hacker2.length; + alert("Wow, you both have equally long names, " + hacker1.length +" characters!"); +} +// Iteration 3: Loops +alert(hacker1.toUpperCase().split("").join(" ")); +alert(hacker2.split("").reverse().join("")); +if (hacker1 < hacker2) { + alert("The driver's name goes first."); +} else if (hacker1 > hacker2) { + alert("Yo, the navigator's name goes first."); +} else { + alert("What?! You both have the same name?"); +} -// Iteration 3: Loops