From efcca35ec462241a7896bc91608ada0b8edbd0cf Mon Sep 17 00:00:00 2001 From: Diogo Santos Date: Tue, 21 Jan 2020 10:44:04 +0000 Subject: [PATCH] We did until the 3.2 interaction. --- js/index.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/js/index.js b/js/index.js index dd8ff0062..a607e0f0b 100644 --- a/js/index.js +++ b/js/index.js @@ -1,7 +1,32 @@ // Iteration 1: Names and Input +var hacker1 = 'Diogo'; +console.log("The driver's name is " + hacker1); +var hacker2 = 'Aline'; +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 (hacker1.length < hacker2.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, ${hacker2.length} characters!`); +} -// Iteration 3: Loops \ No newline at end of file +// Iteration 3: Loops + +var upperCaseVar = ''; +for (i = 0; i < hacker1.length; i++) { + upperCaseVar += hacker1[i].toUpperCase(); +} +console.log(upperCaseVar.split('').join(' ')); + +var reverseString = ''; +for (let j = hacker1.length - 1; j >= 0; j--) { + reverseString += hacker1[j]; +} +console.log(reverseString);