diff --git a/index.js b/index.js index aa0a0fd..1b4f545 100644 --- a/index.js +++ b/index.js @@ -5,10 +5,7 @@ const string1 = "My favorite dessert is jello"; -// Your code here... - - - +console.log(string1.indexOf("j")); /******************************************* Iteration 2 | Concatenate Characters @@ -16,11 +13,13 @@ const string1 = "My favorite dessert is jello"; // Make a new string with the text "COOL" by using only the characters available in the provided string and the bracket notation const string2 = "ABCDEFGHJKLO"; +let c = string2.slice(2, 3); +let o = string2.slice(11); +let l = string2.slice(10, 11); -// Your code here... - - +let cool = `${c} ${o} ${o} ${l}`; +console.log(cool); /***************************************************** Iteration 3 | Repeat a String and Concatenate @@ -28,22 +27,24 @@ const string2 = "ABCDEFGHJKLO"; // Using the method .repeat() and the provided string, print out the text "NaNaNaNa Batman!" in the console. const string3 = "Na"; +const batman = string3.repeat(3) + "" + "Batman!"; -// Your code here... - - +console.log(batman); +// Your code here... /******************************************* - Iteration 4 | Fruite Slice +Iteration 4 | Fruite Slice *******************************************/ // Using the string method .slice(), access and print to the console the name of your favorite fruit from a given string -const fruit = "banana apple mango orange lemon kiwi watermelon grapes pear pineapple"; - -// Your code here... +const fruit = + "banana apple mango orange lemon kiwi watermelon grapes pear pineapple"; +const favFruit = fruit.slice(13, 18); +console.log(favFruit); +// Your code here... /*************************************************** Iteration 5 | Check If Strings Include a Word @@ -55,27 +56,21 @@ 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 ... - - -// Check the second headline -// Your code here ... - - +if (funnyHeadline1.includes("oxygen") === true) { + console.log("The string includes the word 'oxygen'"); +} else { + console.log("The string does not include the word 'oxygen'"); +} /******************************************* - Iteration 6 | String Length -*******************************************/ + * Iteration 6 | String Length + *******************************************/ // Using console.log() print to the console the length of the string and the last character in the string. 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(16));