From d7db56502c4d11db336264c5a8b3ac516dd15202 Mon Sep 17 00:00:00 2001 From: Amr CHATELAIN Date: Thu, 4 Sep 2025 20:02:03 +0200 Subject: [PATCH 1/2] done --- index.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index aa0a0fd..d19b358 100644 --- a/index.js +++ b/index.js @@ -5,7 +5,10 @@ const string1 = "My favorite dessert is jello"; -// Your code here... +const indexOfJ = string1.indexOf("j"); + +console.log(string1[indexOfJ]); + @@ -29,7 +32,7 @@ const string2 = "ABCDEFGHJKLO"; const string3 = "Na"; -// Your code here... +console.log(string3.repeat(4) + " Batman!"); @@ -74,8 +77,14 @@ const string4 = "zEAWrTC9EgtxmK9w1"; // a) Print the string length -// Your code here ... + +console.log(string4.length); // b) Print the last character in the string -// Your code here ... + +console.log(string4.slice(-1)); + +// if you meant the w then it will be + +console.log(string4.slice(-2,-1)); \ No newline at end of file From 918cc74ee9dbf2a010aef5dca3b140e997ccfcaf Mon Sep 17 00:00:00 2001 From: Tanja Mueller Date: Thu, 4 Sep 2025 20:03:06 +0200 Subject: [PATCH 2/2] solved my part --- index.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/index.js b/index.js index aa0a0fd..d138d11 100644 --- a/index.js +++ b/index.js @@ -18,6 +18,8 @@ const string1 = "My favorite dessert is jello"; const string2 = "ABCDEFGHJKLO"; // Your code here... +const cool = string2[2] + string2[string2.length -1] + string2[string2.length -1] + string2[string2.length -2]; +console.log(cool); @@ -42,6 +44,8 @@ const string3 = "Na"; const fruit = "banana apple mango orange lemon kiwi watermelon grapes pear pineapple"; // Your code here... +const favFruit = fruit.slice(fruit.indexOf("m"), fruit.indexOf("mango") + "mango".length); +console.log(favFruit); @@ -58,10 +62,22 @@ const funnyHeadline2 = "Students Cook & Serve Grandparents"; // Check the first headline // Your code here ... +if (funnyHeadline1.includes("oxygen")) { + console.log(`The string includes the word 'oxygen'`) +} +else { + console.log(`This string does not include the word 'oxygen'`) +} // Check the second headline // Your code here ... +if (funnyHeadline2.includes("oxygen")) { + console.log(`The string includes the word 'oxygen'`) +} +else { + console.log(`This string does not include the word 'oxygen'`) +}