From d985f574802db93b9b5d9cee609b10bf5d2974e1 Mon Sep 17 00:00:00 2001 From: Ignacio Sanchez Jurado Date: Fri, 8 Nov 2019 18:51:57 +0100 Subject: [PATCH 1/2] primera version --- js/index.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/js/index.js b/js/index.js index dd8ff0062..f6c24595b 100644 --- a/js/index.js +++ b/js/index.js @@ -1,7 +1,33 @@ // Iteration 1: Names and Input +let hacker1 = "Nacho" +console.log("The driver's name is " + hacker1); +let hacker2 = "Jacinto" +console.log("The navigator's name is " + hacker2); // Iteration 2: Conditionals +let hacker1Length = hacker1.length +let hacker2Length = hacker2.length -// Iteration 3: Loops \ No newline at end of file +if (hacker1Length > hacker2Length) { + console.log(`The driver has the longest name, it has ${hacker1Length} characters`); +} else if (hacker1Length < hacker2Length) { + console.log(`It seems that the navigator has the longest name, it has ${hacker2Length} characters`); +} else { + console.log(`Wow, you both have equally long names, ${hacker1Length} characters!`); +} + +// Iteration 3: Loops + +let hacker1Array = [""] +for (let i = 0; i < hacker1Length; i++) { + hacker1Array = hacker1Array + hacker1[i] + " " +} +console.log(hacker1Array.toUpperCase()) + +let hacker1Array2 = [""] +for (let i = hacker1Length - 1; i >= 0; i--) { + hacker1Array2 = hacker1Array2 + hacker1[i] +} +console.log(hacker1Array2) \ No newline at end of file From 40dae25e38b6530f25e000364474b6c556dcf670 Mon Sep 17 00:00:00 2001 From: Ignacio Sanchez Jurado Date: Fri, 8 Nov 2019 20:18:34 +0100 Subject: [PATCH 2/2] =?UTF-8?q?=C3=9Altima=20version=20con=20el=203.3=20he?= =?UTF-8?q?cho?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/index.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/js/index.js b/js/index.js index f6c24595b..62bcf8d8c 100644 --- a/js/index.js +++ b/js/index.js @@ -30,4 +30,15 @@ let hacker1Array2 = [""] for (let i = hacker1Length - 1; i >= 0; i--) { hacker1Array2 = hacker1Array2 + hacker1[i] } -console.log(hacker1Array2) \ No newline at end of file +console.log(hacker1Array2) + +let hacker1FirstLetter = hacker1[0] +let hacker2FirstLetter = hacker2[0] + +if (hacker1FirstLetter > hacker2FirstLetter) { + console.log(`The driver's name goes first.`); +} else if (hacker1FirstLetter < hacker2FirstLetter) { + console.log(`Yo, the navigator goes first definitely.`); +} else { + console.log(`What?! You both have the same name?`); +}