Skip to content

Commit 1b37294

Browse files
author
Wakidur Rahaman
committed
String Decomposition
1 parent 6c36c35 commit 1b37294

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/exercises/string/exercise-01.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const d = 'ab';
2626

2727
console.log(a < b); // Prints 'false'
2828

29-
// String Search
29+
// 3. String Search
3030

3131
'Red Dragon'.indexOf('Red'); // returns 0;
3232
'Red Dragon'.indexOf('RedScale'); // returns -1
@@ -52,3 +52,14 @@ console.log(count);
5252

5353
'Red Dragon'.startsWith('Red'); // Returns true
5454
'Red Dragon'.endsWith('Dragon'); // Returns true
55+
56+
// 04. String Decomposition
57+
const commaString = 'chicken,noodle,soup,broth';
58+
commaString.split(','); // returns ["chicken", "noodle", "soup", "broth"]
59+
60+
const onlyString = 'chicken';
61+
onlyString.split('');
62+
63+
// 05. String Replace
64+
// .replace(string, replaceString) replaces a specified string within a string variable with another string.
65+
'Wizard of Oz'.replace('Wizard', 'Witch'); // 'Witch of Oz';

0 commit comments

Comments
 (0)