Skip to content

Commit 6e5558f

Browse files
committed
modified strings
1 parent ce4948b commit 6e5558f

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

common-string-methods.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,23 @@ Complete the following tasks and assign the results to the specified variables.
6969
let inputString = " Welcome to the Coding Bootcamp! Learn JavaScript today. ";
7070

7171
// 1. Searching
72-
let hasJavaScript; // Your code here
73-
let codingPosition; // Your code here
74-
let startsWithWelcome; // Your code here
75-
let endsWithToday; // Your code here
72+
let hasJavaScript = inputString.includes("JavaScript"); // check if inputSring includes "JavaScript"
73+
let codingPosition = inputString.indexOf("Coding"); // Find the position of the word "Coding" in the string using indexOf
74+
let startsWithWelcome = inputString.startsWith("Welcome"); // Check if the string starts with "Welcome"
75+
let endsWithToday = inputString.endsWith("today."); // Check if the string ends with "today."
7676

7777
// 2. Transforming
78-
let lowercaseString; // Your code here
79-
let uppercaseString; // Your code here
80-
let trimmedString; // Your code here
81-
let replacedString; // Your code here
78+
let lowercaseString = inputString.toLocaleLowerCase(); // Convert the string to all lowercase letters using toLowerCase
79+
let uppercaseString = inputString.toLocaleUpperCase(); // . Convert the string to all uppercase letters using toUpperCase
80+
let trimmedString = inputString.trim(); // Remove the extra spaces from the beginning and end of the string using
81+
let replacedString = inputString.replace("JavaScript", "coding"); // Replace the word "JavaScript" with "coding"
8282

8383
// 3. Breaking Apart
84-
let wordsArray; // Your code here
84+
let wordsArray = inputString.split(" "); // Split the string into an array of words using split with a space (" ") as the delimiter
8585

8686
// 4. Retrieving
87-
let firstCharacter; // Your code here
88-
let extractedBootcamp; // Your code here
87+
let firstCharacter = trimmedString.charAt(0); // Retrieve the first character of the trimmed string using charAt
88+
let extractedBootcamp = inputString.slice(24,32); // Extract the word "Bootcamp" from the string using slice
8989

9090
// Log all results
9191
console.log({

0 commit comments

Comments
 (0)