From 1740134128735f5ef62c5573ffb7dcc221a4e204 Mon Sep 17 00:00:00 2001 From: Ruben Date: Sat, 23 Jun 2018 13:13:10 +0200 Subject: [PATCH] =?UTF-8?q?Iteraci=C3=B3n=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- starter-code/basic-algorithms.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/starter-code/basic-algorithms.js b/starter-code/basic-algorithms.js index 82f20d8ba..1e411a59a 100644 --- a/starter-code/basic-algorithms.js +++ b/starter-code/basic-algorithms.js @@ -1,7 +1,39 @@ // Names and Input +var hacker1 = "ruben"; +console.log("The driver's name is " + hacker1); +var hacker2 = "pablo"; +console.log("The navigator's name is " + hacker2); //Conditionals +if (hacker1.length > hacker2.length) { + console.log("The Driver has the longest name, it has 5 characters") +} else if (hacker1.length < hacker2.length) { + console.log("The navigator has the longest name, it has 4 characters") +} else { + console.log("Wow, you both got equally long names, 5 characters!!") +} + +var driverNameSpaced = ""; + +for (var i = 0; i < hacker1.length; i++) { + hacker1 = hacker1.toUpperCase(); + driverNameSpaced += hacker1[i]; + driverNameSpaced += " "; +} + +console.log("Driver name: " + driverNameSpaced); + +var navigatorNameReverse = ""; + +for (var i = 0; i < hacker2.length; i++) { + var navigatorNameReverse = hacker2.split('').reverse().join(''); +} +console.log(navigatorNameReverse); // Lorem ipsum generator + + + +