From 6384fcefa5a7ce55c4ff5b65f4ca41dc2ca4fd1f Mon Sep 17 00:00:00 2001 From: kritikamandale Date: Sat, 13 Sep 2025 17:26:43 +0530 Subject: [PATCH 1/4] yes ready to begin --- js/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/index.js b/js/index.js index 59e4af7..6a2aa41 100644 --- a/js/index.js +++ b/js/index.js @@ -4,3 +4,4 @@ // Iteration 3: Loops +console.log("I'm ready!"); \ No newline at end of file From 83762e6318d823edeb940c9362ef5e78bbfa67a6 Mon Sep 17 00:00:00 2001 From: kritikamandale Date: Sat, 13 Sep 2025 17:52:11 +0530 Subject: [PATCH 2/4] iteration 1 and iteration 2 done --- js/index.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/js/index.js b/js/index.js index 6a2aa41..2b5c564 100644 --- a/js/index.js +++ b/js/index.js @@ -1,7 +1,20 @@ +console.log("I'm ready!"); // Iteration 1: Names and Input -// -// Iteration 2: Conditionals +var hacker1 = "harry"; +console.log("The driver's name is " + hacker1 + "."); + +var hacker2 = "hermione"; +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, " + hacker1.length + " characters!") +} + // Iteration 3: Loops -console.log("I'm ready!"); \ No newline at end of file + From 63781ea2424d64c4ccc9623d2f09b9beed0e8b48 Mon Sep 17 00:00:00 2001 From: kritikamandale Date: Sat, 13 Sep 2025 17:56:35 +0530 Subject: [PATCH 3/4] iteration 3 done --- js/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/js/index.js b/js/index.js index 2b5c564..7dab165 100644 --- a/js/index.js +++ b/js/index.js @@ -17,4 +17,11 @@ if (hacker1.length > hacker2.length) { } // Iteration 3: Loops - +for (var i = 0; i < hacker1.length; i++) { + console.log(hacker1[i].toUpperCase()); +} +var reversedName = ""; +for (var i = hacker2.length - 1; i >= 0; i--) { + reversedName += hacker2[i]; +} +console.log(reversedName); From caedb0890fe81e899bfccbc98db4ae81f290d2e5 Mon Sep 17 00:00:00 2001 From: kritikamandale Date: Sat, 13 Sep 2025 18:02:49 +0530 Subject: [PATCH 4/4] bonus 1 solved --- js/index.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/js/index.js b/js/index.js index 7dab165..0cd027e 100644 --- a/js/index.js +++ b/js/index.js @@ -25,3 +25,23 @@ for (var i = hacker2.length - 1; i >= 0; i--) { reversedName += hacker2[i]; } console.log(reversedName); + +// Bonus 1 +var lorem = "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?" + +var wordCount = 0; +for (var i = 0; i < lorem.length; i++) { + if (lorem[i] === " ") { + wordCount++; + } +} +wordCount++; // Count the last word +console.log("Word count: " + wordCount); + +var etCount = 0; +for (var i = 0; i < lorem.length - 1; i++) { + if (lorem[i] === "e" && lorem[i + 1] === "t") { + etCount++; + } +} +console.log("The 'et' substring appears " + etCount + " times."); \ No newline at end of file