diff --git a/index.js b/index.js index aa0a0fd..771cdc6 100644 --- a/index.js +++ b/index.js @@ -7,7 +7,7 @@ const string1 = "My favorite dessert is jello"; // Your code here... - +console.log(string1.indexOf("j")); /******************************************* @@ -19,7 +19,11 @@ const string2 = "ABCDEFGHJKLO"; // Your code here... +console.log(string2.indexOf("C")); +console.log(string2.indexOf("O")); +console.log(string2.indexOf("L")); +console.log(string2[2] + string2[11] + string2[11] + string2[10]); /***************************************************** @@ -30,7 +34,7 @@ const string2 = "ABCDEFGHJKLO"; const string3 = "Na"; // Your code here... - +console.log(string3.repeat(4) + " Batman!"); @@ -43,7 +47,9 @@ const fruit = "banana apple mango orange lemon kiwi watermelon grapes pear pinea // Your code here... +favouriteFruit = fruit.indexOf("grapes"); +console.log(fruit.slice(favouriteFruit, favouriteFruit + 6)); // "grapes" /*************************************************** Iteration 5 | Check If Strings Include a Word @@ -55,14 +61,22 @@ const fruit = "banana apple mango orange lemon kiwi watermelon grapes pear pinea const funnyHeadline1 = "Breathing oxygen linked to staying alive"; const funnyHeadline2 = "Students Cook & Serve Grandparents"; - // Check the first headline // Your code here ... +if (funnyHeadline1.includes("oxygen")) { + console.log(`${funnyHeadline1} - The string includes the word 'oxygen'`); + } else { + console.log(`${funnyHeadline1} - The string does not include the word 'oxygen'`); +} // Check the second headline // Your code here ... - +if (funnyHeadline2.includes("oxygen")) { + console.log(`${funnyHeadline2} - The string includes the word 'oxygen'`); + } else { + console.log(`${funnyHeadline2} - The string does not include the word 'oxygen'`); +} /******************************************* @@ -75,7 +89,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.charAt(string4.length - 1)); \ No newline at end of file