@@ -65,27 +65,56 @@ Complete the following tasks and assign the results to the specified variables.
65
65
66
66
*/
67
67
68
+ //Practice Problem #1
69
+ //Activity 1: Searching Strings
70
+ let practiceOneActivityOne = "Learning JavaScript is fun!" ;
71
+ console . log ( practiceOneActivityOne . includes ( "JavaScript" ) ) ;
72
+ console . log ( practiceOneActivityOne . indexOf ( "fun" ) ) ;
73
+ //Activity 2: Transforming Strings
74
+ let practiceOneActivityTwo = " CODE BOOTCAMP "
75
+ console . log ( practiceOneActivityTwo . toLowerCase ( ) . trim ( ) . replace ( "bootcamp" , "JavaScript" ) ) ;
76
+ //Activity 3: Breaking Apart a Sentence
77
+ let practiceOneActivityThree = "Coding is fun and educational" ;
78
+ let revisedOneThree = practiceOneActivityThree . split ( " " ) ;
79
+ console . log ( revisedOneThree ) ;
80
+ //Activity 4: Retrieving Substrings
81
+ let practiceOneActivityFour = "Bootcamp" ;
82
+ console . log ( practiceOneActivityFour . charAt ( 0 ) ) ;
83
+ console . log ( practiceOneActivityFour . slice ( - 4 ) ) ;
84
+ //Advanced Challenge, I had to use ChatGPT to find out how to find the starting point of Order
85
+ //If that is incorrect and we learned a different way, I will need guidance on how to achieve that
86
+ let advancedChallenge = `Customer: John Doe
87
+ Order: Apple, Banana, Grape
88
+ Total: $20.50` ;
89
+ console . log ( advancedChallenge . slice ( 10 , 19 ) ) ;
90
+ let orderLine = advancedChallenge . split ( "\n" ) . find ( line => line . startsWith ( "Order:" ) ) ;
91
+ let itemSplit = orderLine . replace ( "Order: " , "" ) . split ( ", " ) ;
92
+ console . log ( itemSplit ) ;
93
+ let totalUpper = advancedChallenge . replace ( "Total" , "TOTAL" ) ;
94
+ console . log ( totalUpper )
95
+
96
+
68
97
//Starter Code
69
98
let inputString = " Welcome to the Coding Bootcamp! Learn JavaScript today. " ;
70
99
71
100
// 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
101
+ let hasJavaScript = ( inputString . includes ( "JavaScript" ) ) ;
102
+ let codingPosition = ( inputString . indexOf ( "Coding" ) ) ;
103
+ let startsWithWelcome = ( inputString . startsWith ( "Welcome" ) ) ;
104
+ let endsWithToday = ( inputString . endsWith ( "today" ) ) ;
76
105
77
106
// 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
107
+ let lowercaseString = ( inputString . toLowerCase ( ) ) ;
108
+ let uppercaseString = ( inputString . toUpperCase ( ) ) ;
109
+ let trimmedString = ( inputString . trim ( ) ) ;
110
+ let replacedString = ( inputString . replace ( "JavaScript" , "coding" ) ) ;
82
111
83
112
// 3. Breaking Apart
84
- let wordsArray ; // Your code here
113
+ let wordsArray = ( inputString . split ( " " ) ) ;
85
114
86
115
// 4. Retrieving
87
- let firstCharacter ; // Your code here
88
- let extractedBootcamp ; // Your code here
116
+ let firstCharacter = ( inputString . trim ( ) . charAt ( 0 ) ) ;
117
+ let extractedBootcamp = ( inputString . slice ( 24 , 33 ) ) ;
89
118
90
119
// Log all results
91
120
console . log ( {
0 commit comments