diff --git a/index.js b/index.js index aa0a0fd..041d668 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,7 @@ const string1 = "My favorite dessert is jello"; // Your code here... - +console.log(string1.indexOf('j')); @@ -18,7 +18,10 @@ const string1 = "My favorite dessert is jello"; const string2 = "ABCDEFGHJKLO"; // Your code here... - +console.log(string2[string2.indexOf('C')]+ +string2[string2.indexOf('O')]+ +string2[string2.indexOf('O')]+ +string2[string2.indexOf('L')]) @@ -30,7 +33,7 @@ const string2 = "ABCDEFGHJKLO"; const string3 = "Na"; // Your code here... - +console.log(`${"Na".repeat(4)} Batman!`); @@ -42,7 +45,10 @@ const string3 = "Na"; const fruit = "banana apple mango orange lemon kiwi watermelon grapes pear pineapple"; // Your code here... - +const favFruit = "lemon"; +const favFruitIndex = fruit.indexOf(favFruit) +const favFruitLentgh = favFruit.length +console.log(fruit.slice(favFruitIndex,favFruitIndex+favFruitLentgh)) /*************************************************** @@ -58,11 +64,19 @@ 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("The 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("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[string4.length-1]); \ No newline at end of file