diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..6f3a291 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} \ No newline at end of file diff --git a/index.js b/index.js index aa0a0fd..2727d6d 100644 --- a/index.js +++ b/index.js @@ -4,8 +4,7 @@ // 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... +console.log(string1.indexOf('j')); @@ -16,8 +15,8 @@ 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"; - -// Your code here... +const stringNew = string2[string2.indexOf('C')] + string2[string2.indexOf('O')] + string2[string2.indexOf('O')] + string2[string2.indexOf('L')]; +console.log(stringNew); @@ -28,8 +27,9 @@ const string2 = "ABCDEFGHJKLO"; // Using the method .repeat() and the provided string, print out the text "NaNaNaNa Batman!" in the console. const string3 = "Na"; +const character = string3.repeat(3) + ' Batman!'; +console.log(character); -// Your code here... @@ -40,8 +40,9 @@ const string3 = "Na"; // 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 fruitSelect = 'kiwi'; +const i = fruit.indexOf(fruitSelect); +console.log(fruit.slice(i, i + fruitSelect.length)); @@ -54,14 +55,14 @@ 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"; - - +const word = "oxygen"; +const message1 = "The string includes the word 'oxygen'"; +const message2 = "The string does not include the word 'oxygen'"; // Check the first headline -// Your code here ... - +console.log(funnyHeadline1.includes(word) ? message1 : message2); // Check the second headline -// Your code here ... +console.log(funnyHeadline2.includes(word) ? message1 : message2); @@ -72,10 +73,9 @@ const funnyHeadline2 = "Students Cook & Serve Grandparents"; 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(-1));