From 7e34dfb67f7e523b0068629d7613b54619807401 Mon Sep 17 00:00:00 2001 From: rbc33 Date: Thu, 4 Sep 2025 19:06:01 +0200 Subject: [PATCH 1/3] Solved lab --- .vscode/settings.json | 3 +++ index.js | 53 +++++++++++++++++++++---------------------- 2 files changed, 29 insertions(+), 27 deletions(-) create mode 100644 .vscode/settings.json 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..96ef7ff 100644 --- a/index.js +++ b/index.js @@ -3,48 +3,45 @@ *******************************************/ // 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"; - -// Your code here... - - +const string2 = 'ABCDEFGHJKLO' +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 +49,32 @@ 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'") +funnyHeadline2.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 ... - - /******************************************* 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' +console.log(string4.length) +console.log(string4[string4.length - 1]) // a) Print the string length // Your code here ... - // b) Print the last character in the string // Your code here ... From fa9b403da2e83ba8859fe0f37fbdcdc63a032bd9 Mon Sep 17 00:00:00 2001 From: rbc33 Date: Thu, 4 Sep 2025 19:07:39 +0200 Subject: [PATCH 2/3] Solved lab --- index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 96ef7ff..9809340 100644 --- a/index.js +++ b/index.js @@ -70,11 +70,10 @@ funnyHeadline2.includes('oxygen') const string4 = 'zEAWrTC9EgtxmK9w1' -console.log(string4.length) -console.log(string4[string4.length - 1]) - // 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]) From 324045593d7907f61d72e32b81be761d06139b07 Mon Sep 17 00:00:00 2001 From: rbc33 Date: Fri, 5 Sep 2025 01:22:57 +0200 Subject: [PATCH 3/3] Solved lab --- index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 9809340..2ad39cd 100644 --- a/index.js +++ b/index.js @@ -14,6 +14,7 @@ console.log(string1.indexOf('j')) const string2 = 'ABCDEFGHJKLO' +// Your code here... const newString = string2[string2.indexOf('C')] + string2[string2.indexOf('O')] + @@ -56,12 +57,12 @@ const funnyHeadline2 = 'Students Cook & Serve Grandparents' funnyHeadline1.includes('oxygen') ? console.log("The string include the word 'oxygen'") : console.log("The string does not include the word 'oxygen'") -funnyHeadline2.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