diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..f673a71 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5502 +} \ No newline at end of file diff --git a/index.js b/index.js index aa0a0fd..2ad39cd 100644 --- a/index.js +++ b/index.js @@ -3,48 +3,46 @@ *******************************************/ // Write code that prints out to the console the index of the character ā€œjā€ in -const string1 = "My favorite dessert is jello"; - -// Your code here... - - +const string1 = 'My favorite dessert is jello' +console.log(string1.indexOf('j')) /******************************************* Iteration 2 | Concatenate Characters *******************************************/ // 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"; +const string2 = 'ABCDEFGHJKLO' // Your code here... - - - +const newString = + string2[string2.indexOf('C')] + + string2[string2.indexOf('O')] + + string2[string2.indexOf('O')] + + string2[string2.indexOf('L')] +console.log(newString) /***************************************************** Iteration 3 | Repeat a String and Concatenate *****************************************************/ // Using the method .repeat() and the provided string, print out the text "NaNaNaNa Batman!" in the console. -const string3 = "Na"; +const string3 = 'Na' // Your code here... - - - +console.log(string3.repeat(4), ' Batman!') /******************************************* 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"; +const fruit = + 'banana apple mango orange lemon kiwi watermelon grapes pear pineapple' // Your code here... - - - +const favFruit = fruit.slice(7, 13) +console.log(favFruit) /*************************************************** Iteration 5 | Check If Strings Include a Word ***************************************************/ @@ -52,30 +50,31 @@ const fruit = "banana apple mango orange lemon kiwi watermelon grapes pear pinea // If a string includes the word "oxygen" print to the console message "The string includes the word 'oxygen'", // else print the message "The string does not include the word 'oxygen'". -const funnyHeadline1 = "Breathing oxygen linked to staying alive"; -const funnyHeadline2 = "Students Cook & Serve Grandparents"; - +const funnyHeadline1 = 'Breathing oxygen linked to staying alive' +const funnyHeadline2 = 'Students Cook & Serve Grandparents' // Check the first headline -// Your code here ... - +funnyHeadline1.includes('oxygen') + ? console.log("The string include the word 'oxygen'") + : console.log("The string does not include the word 'oxygen'") // Check the second headline // Your code here ... - - +funnyHeadline2.includes('oxygen') + ? console.log("The string include the word 'oxygen'") + : console.log("The string does not include the word 'oxygen'") /******************************************* 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"; - +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])