From b8baec02733f02a5f85822b450a0f41ea9cbe478 Mon Sep 17 00:00:00 2001 From: Carlos Canet Date: Tue, 22 Jul 2025 21:47:44 +0200 Subject: [PATCH] Lab done! Why so serious? --- index.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index aa0a0fd..cc65245 100644 --- a/index.js +++ b/index.js @@ -5,8 +5,7 @@ const string1 = "My favorite dessert is jello"; -// Your code here... - +console.log(string1.indexOf("j")); @@ -17,7 +16,7 @@ const string1 = "My favorite dessert is jello"; const string2 = "ABCDEFGHJKLO"; -// Your code here... +const coolString = string2[2] + string2[14] + string2[14] + string2[11]; @@ -29,7 +28,7 @@ const string2 = "ABCDEFGHJKLO"; const string3 = "Na"; -// Your code here... +console.log(string3.repeat(4) + " Batman!"); @@ -41,7 +40,7 @@ const string3 = "Na"; const fruit = "banana apple mango orange lemon kiwi watermelon grapes pear pineapple"; -// Your code here... +console.log(fruit.slice(fruit.indexOf("pineapple"), fruit.indexOf("pineapple") + "pineapple".length)); @@ -57,11 +56,10 @@ const funnyHeadline2 = "Students Cook & Serve Grandparents"; // Check the first headline -// Your code here ... - +console.log(funnyHeadline1.includes("oxygen") ? "The string includes the word 'oxygen'" : "The string does not include the word 'oxygen'"); // Check the second headline -// Your code here ... +console.log(funnyHeadline2.includes("oxygen") ? "The string includes the word 'oxygen'" : "The string does not include the word 'oxygen'"); @@ -74,8 +72,8 @@ 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[string4.length-1])