diff --git a/index.js b/index.js index 6b0fec3ad..56ef99f2a 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,108 @@ // Iteration 1: Names and Input +const hacker1 = "Ferran"; +console.log("The driver's name is " + hacker1); + + +const hacker2 = "Ramos"; +console.log("The navigator's name is " + hacker2); + // Iteration 2: Conditionals +const name1 = hacker1.length; +const name2 = hacker2.length; + +if (name1 > name2) { + console.log("The driver has the longest name, it has " + name1 + " characters."); + document.body.innerHTML = ` +
The driver's name is ${hacker1}
+The navigator's name is ${hacker2}
+The driver has the longest name, it has ${name1} characters.
+ `; +} else if (name1 < name2) { + console.log("It seems that the navigator has the longest name, it has " + name2 + " characters."); + document.body.innerHTML = ` +The driver's name is ${hacker1}
+The navigator's name is ${hacker2}
+It seems that the navigator has the longest name, it has ${name2} characters.
+ `; +} else { + console.log("Wow, you both have equally long names, XX characters!."); + document.body.innerHTML = ` +The driver's name is ${hacker1}
+The navigator's name is ${hacker2}
+Wow, you both have equally long names, it has ${name2} characters.
+ `; +} + // Iteration 3: Loops + +let res = ""; + +for (let i = 0; i < hacker1.length; i++) { + res += hacker1[i].toUpperCase(); + if (i < hacker1.length - 1) + res += " "; +} + +console.log(res); +document.body.innerHTML = ` +The driver's name is ${hacker1}
+The navigator's name is ${hacker2}
+Wow, you both have equally long names, it has ${name2} characters.
+The driver's name is ${hacker1}
+The navigator's name is ${hacker2}
+Wow, you both have equally long names, it has ${name2} characters.
+The driver's name is ${hacker1}
+The navigator's name is ${hacker2}
+Wow, you both have equally long names, it has ${name2} characters.
+