From 6a9896c78fcb9bcf83df233e935ab5757159fc9f Mon Sep 17 00:00:00 2001 From: Mihhedkol Date: Thu, 11 Aug 2022 18:04:12 +0200 Subject: [PATCH 1/5] javascript Iteration 1 --- js/index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/js/index.js b/js/index.js index 59e4af7fb..9af93e2db 100644 --- a/js/index.js +++ b/js/index.js @@ -1,5 +1,15 @@ +console.log("I'm ready!"); + // Iteration 1: Names and Input -// + +const hacker1 = "Pol" + +console.log(`The driver's name is ${hacker1}`) + +const hacker2 = "Marc" + +console.log(`The navigator's name is ${hacker2}`) + // Iteration 2: Conditionals From b892646ed83e7e1ebe2b3825e62b9167a388273d Mon Sep 17 00:00:00 2001 From: Mihhedkol Date: Thu, 11 Aug 2022 21:24:08 +0200 Subject: [PATCH 2/5] Iteration 2 --- js/index.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/js/index.js b/js/index.js index 9af93e2db..c37010189 100644 --- a/js/index.js +++ b/js/index.js @@ -2,15 +2,25 @@ console.log("I'm ready!"); // Iteration 1: Names and Input -const hacker1 = "Pol" +const hacker1 = "Marc" console.log(`The driver's name is ${hacker1}`) -const hacker2 = "Marc" +const hacker2 = "Jelizaveta" console.log(`The navigator's name is ${hacker2}`) // Iteration 2: Conditionals +const driverLength = hacker1.length +const navigatorLength = hacker2.length + +if (driverLength > navigatorLength) { + console.log(`The driver has the longest name, it has ${driverLength} characters.`) +} else if (driverLength < navigatorLength) { + console.log(`It seems that the navigator has the longest name, it has ${navigatorLength} characters.`) +} else { + console.log(`Wow, you both have equally long names, ${driverLength} characters!`) +} // Iteration 3: Loops From d2d1e6e371315b5c77fc609ca9edebb3e1dd73ee Mon Sep 17 00:00:00 2001 From: Mihhedkol Date: Thu, 11 Aug 2022 22:06:38 +0200 Subject: [PATCH 3/5] Iteration 3 --- js/index.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/js/index.js b/js/index.js index c37010189..e47f0129d 100644 --- a/js/index.js +++ b/js/index.js @@ -2,11 +2,11 @@ console.log("I'm ready!"); // Iteration 1: Names and Input -const hacker1 = "Marc" +const hacker1 = "Ada" console.log(`The driver's name is ${hacker1}`) -const hacker2 = "Jelizaveta" +const hacker2 = "John" console.log(`The navigator's name is ${hacker2}`) @@ -24,3 +24,17 @@ if (driverLength > navigatorLength) { } // Iteration 3: Loops + +console.log(hacker1.toUpperCase().split("").join(" ")) + +console.log(hacker2.split("").reverse().join("")) + +if (hacker1 < hacker2) { + console.log("The driver's name goes first") +} else if (hacker2 < hacker1) { + console.log("Yo, the navigator goes first definitely.") +} else if (hacker1 === hacker2) { + console.log("What?! You both have the same name?") +} + + From 9327cbb792cca4d38077bc0c1a9955ab913af2f6 Mon Sep 17 00:00:00 2001 From: Mihhedkol Date: Sat, 13 Aug 2022 09:02:43 +0200 Subject: [PATCH 4/5] Iteration 3 --- js/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/js/index.js b/js/index.js index e47f0129d..084e88378 100644 --- a/js/index.js +++ b/js/index.js @@ -36,5 +36,3 @@ if (hacker1 < hacker2) { } else if (hacker1 === hacker2) { console.log("What?! You both have the same name?") } - - From 62e6ceda4f16a004205e56298f9e1febde26ab38 Mon Sep 17 00:00:00 2001 From: Mihhedkol Date: Sat, 13 Aug 2022 09:59:42 +0200 Subject: [PATCH 5/5] Iteration 3 version 2 --- js/index.js | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/js/index.js b/js/index.js index 084e88378..c0d135e59 100644 --- a/js/index.js +++ b/js/index.js @@ -2,7 +2,7 @@ console.log("I'm ready!"); // Iteration 1: Names and Input -const hacker1 = "Ada" +const hacker1 = "Jelizaveta" console.log(`The driver's name is ${hacker1}`) @@ -25,9 +25,30 @@ if (driverLength > navigatorLength) { // Iteration 3: Loops -console.log(hacker1.toUpperCase().split("").join(" ")) +//3.1 -console.log(hacker2.split("").reverse().join("")) +// console.log(hacker1.toUpperCase().split("").join(" ")) + +let str = ''; + +for (let i = 0; i < hacker1.length; i++) { + str += hacker1[i].toUpperCase() + " "; +} +console.log(str); + +//3.2 + +// console.log(hacker2.split("").reverse().join("")) + +let reversedStr = ''; + +for(i = hacker2.length - 1; i >= 0; i--){ + reversedStr += hacker2[i]; +} + +console.log(reversedStr); + +//3.3 if (hacker1 < hacker2) { console.log("The driver's name goes first") @@ -36,3 +57,5 @@ if (hacker1 < hacker2) { } else if (hacker1 === hacker2) { console.log("What?! You both have the same name?") } + +