@@ -69,23 +69,23 @@ Complete the following tasks and assign the results to the specified variables.
69
69
let inputString = " Welcome to the Coding Bootcamp! Learn JavaScript today. " ;
70
70
71
71
// 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."
76
76
77
77
// 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"
82
82
83
83
// 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
85
85
86
86
// 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
89
89
90
90
// Log all results
91
91
console . log ( {
0 commit comments