You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`.charAt()`|`sipAt`| Returns the character of a string at given index (like taking a single sip of coffee). |
24
+
|`.concat()`|`addMilk`| Concatenates a string to another separated with delimiter (like pouring milk into a cup of coffee). |
24
25
|`.includes()`|`hasMilk`| Returns true if given string is found within this string and false if not (like checking if coffee has milk or not). |
25
26
|`.length`|`brewLength`| Returns the length of a string (how "long" the brew is). |
26
27
|`=`|`pourCoffee`| Copies one string to another (like pouring coffee into a new cup). |
@@ -43,7 +44,18 @@ let brew = "coffee";
43
44
console.log(sipAt(brew, 2)); // f
44
45
```
45
46
46
-
2.`hasMilk(str, word)`
47
+
2.`addMilk(str1, str2, delimiter)`
48
+
Concatenates a string to another separated with delimiter (like pouring milk into a cup of coffee).
49
+
Returns a `string`:
50
+
51
+
```js
52
+
let brew ="coffee";
53
+
let milk ="tastes very good with milk";
54
+
let delimiter =", ";
55
+
console.log(addMilk(brew, milk, delimiter)); // coffee, tastes very good with milk
56
+
```
57
+
58
+
3.`hasMilk(str, word)`
47
59
Checks if word is found within string (like checking if coffee has milk or not).
48
60
Returns `true` if word is in string, `false` if not:
49
61
@@ -53,7 +65,7 @@ let word = "good";
53
65
console.log(hasMilk(sentence, word)); // true
54
66
```
55
67
56
-
3.`brewLength(str)`
68
+
4.`brewLength(str)`
57
69
Calculates the length of the input string (how "long" the brew is).
58
70
Returns the length as `number`:
59
71
@@ -62,7 +74,7 @@ let brew = "coffee";
62
74
console.log(brewLength(brew)); // 6
63
75
```
64
76
65
-
4.`pourCoffee(str)`
77
+
5.`pourCoffee(str)`
66
78
Copies one string to another (like pouring coffee into a new cup).
67
79
Returns the copy as `string`:
68
80
@@ -72,7 +84,7 @@ let cup = pourCoffee(original);
72
84
console.log(cup); // "latte"
73
85
```
74
86
75
-
5.`compareBeans(str1, str2)`
87
+
6.`compareBeans(str1, str2)`
76
88
Compares two strings (like comparing coffee beans for quality). Returns a `number`:
77
89
78
90
-`0` if the strings are identical.
@@ -84,23 +96,23 @@ let result = compareBeans("espresso", "latte");
84
96
console.log(result); // 1 ('e' > 'l')
85
97
```
86
98
87
-
6.`findFirstSip(str, char)`
99
+
7.`findFirstSip(str, char)`
88
100
Finds the first occurrence of a character in a string (like the first sip of coffee). Returns the substring from the first occurrence of the character as `string`:
0 commit comments