From 20d8d9714ad611b9644c40b77d7c574cec4c6f93 Mon Sep 17 00:00:00 2001 From: Edison Abdiel Date: Thu, 30 Jan 2020 21:32:57 +0100 Subject: [PATCH 1/2] done --- js/index.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/js/index.js b/js/index.js index dd8ff0062..e9721d64e 100644 --- a/js/index.js +++ b/js/index.js @@ -1,7 +1,32 @@ // Iteration 1: Names and Input +let hacker1 = 'Adam' +let hacker2 = 'Max' + +console.log(`The driver's name is ${hacker1}`) +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.`) +} + +// Iteration 3: Loops + +let result = '' + +for (i = 0; i < hacker1.length; i++){ + + result += hacker1[i].toUpperCase() + " " +} +console.log(result) + +let reversedResult = "" + +for ( let i = hacker2.length - 1; i >= 0; i--){ + reversedResult += hacker2[i] + +} -// Iteration 3: Loops \ No newline at end of file +console.log(reversedResult) From ddd4f639e753e279839fd9cc10747172c9254ee5 Mon Sep 17 00:00:00 2001 From: Edison Abdiel Date: Sat, 1 Feb 2020 12:45:26 +0100 Subject: [PATCH 2/2] Modifications to the JS lab --- js/index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/js/index.js b/js/index.js index e9721d64e..f726a9a26 100644 --- a/js/index.js +++ b/js/index.js @@ -10,6 +10,10 @@ console.log(`The navigator's name is ${hacker2}`) if (hacker1.length > hacker2.length){ console.log(`The driver has the longest name, it has ${hacker1.length} characters.`) +} else if (hacker2.length > hacke1.length){ + console.log(`The navigator has the longest name, it has ${hacker2.length} characters.`) +} else { + console.log(`Both your hackers have the same length, they both have ${hacker1.length}`) } // Iteration 3: Loops @@ -30,3 +34,10 @@ for ( let i = hacker2.length - 1; i >= 0; i--){ } console.log(reversedResult) + + +console.log(hacker1.substring(0, 1)); + +console.log(hacker2.substring(0, 1)); + +for () \ No newline at end of file