-
Notifications
You must be signed in to change notification settings - Fork 93
/
Copy path01-strings-tasks.js
286 lines (270 loc) · 7.23 KB
/
01-strings-tasks.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
/* *******************************************************************************************
* *
* Please read the following tutorial before implementing tasks: *
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String *
* *
******************************************************************************************* */
/**
* Returns the result of concatenation of two strings.
*
* @param {string} value1
* @param {string} value2
* @return {string}
*
* @example
* 'aa', 'bb' => 'aabb'
* 'aa','' => 'aa'
* '', 'bb' => 'bb'
*/
function concatenateStrings(/* value1, value2 */) {
throw new Error('Not implemented');
}
/**
* Returns the length of given string.
*
* @param {string} value
* @return {number}
*
* @example
* 'aaaaa' => 5
* 'b' => 1
* '' => 0
*/
function getStringLength(/* value */) {
throw new Error('Not implemented');
}
/**
* Returns the result of string template and given parameters firstName and lastName.
* Please do not use concatenation, use template string :
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/template_strings
*
* @param {string} firstName
* @param {string} lastName
* @return {string}
*
* @example
* 'John','Doe' => 'Hello, John Doe!'
* 'Chuck','Norris' => 'Hello, Chuck Norris!'
*/
function getStringFromTemplate(/* firstName, lastName */) {
throw new Error('Not implemented');
}
/**
* Extracts a name from template string 'Hello, First_Name Last_Name!'.
*
* @param {string} value
* @return {string}
*
* @example
* 'Hello, John Doe!' => 'John Doe'
* 'Hello, Chuck Norris!' => 'Chuck Norris'
*/
function extractNameFromTemplate(/* value */) {
throw new Error('Not implemented');
}
/**
* Returns a first char of the given string.
*
* @param {string} value
* @return {string}
*
* @example
* 'John Doe' => 'J'
* 'cat' => 'c'
*/
function getFirstChar(/* value */) {
throw new Error('Not implemented');
}
/**
* Removes a leading and trailing whitespace characters from string.
*
* @param {string} value
* @return {string}
*
* @example
* ' Abracadabra' => 'Abracadabra'
* 'cat' => 'cat'
* '\tHello, World! ' => 'Hello, World!'
*/
function removeLeadingAndTrailingWhitespaces(/* value */) {
throw new Error('Not implemented');
}
/**
* Returns a string that repeated the specified number of times.
*
* @param {string} value
* @param {string} count
* @return {string}
*
* @example
* 'A', 5 => 'AAAAA'
* 'cat', 3 => 'catcatcat'
*/
function repeatString(/* value, count */) {
throw new Error('Not implemented');
}
/**
* Remove the first occurrence of string inside another string
*
* @param {string} str
* @param {string} value
* @return {string}
*
* @example
* 'To be or not to be', 'not' => 'To be or to be'
* 'I like legends', 'end' => 'I like legs',
* 'ABABAB','BA' => 'ABAB'
*/
function removeFirstOccurrences(/* str, value */) {
throw new Error('Not implemented');
}
/**
* Remove the first and last angle brackets from tag string
*
* @param {string} str
* @return {string}
*
* @example
* '<div>' => 'div'
* '<span>' => 'span'
* '<a>' => 'a'
*/
function unbracketTag(/* str */) {
throw new Error('Not implemented');
}
/**
* Converts all characters of the specified string into the upper case
*
* @param {string} str
* @return {string}
*
* @example
* 'Thunderstruck' => 'THUNDERSTRUCK'
* 'abcdefghijklmnopqrstuvwxyz' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
*/
function convertToUpperCase(/* str */) {
throw new Error('Not implemented');
}
/**
* Extracts e-mails from single string with e-mails list delimeted by semicolons
*
* @param {string} str
* @return {array}
*
* @example
* 'angus.young@gmail.com;brian.johnson@hotmail.com;bon.scott@yahoo.com'
* => [
* 'angus.young@gmail.com',
* 'brian.johnson@hotmail.com',
* 'bon.scott@yahoo.com'
* ],
* 'info@gmail.com' => ['info@gmail.com']
*/
function extractEmails(/* str */) {
throw new Error('Not implemented');
}
/**
* Returns the string representation of rectangle with specified width and height
* using pseudograhic chars
*
* @param {number} width
* @param {number} height
* @return {string}
*
* @example
*
* '┌────┐\n'+
* (6,4) => '│ │\n'+
* '│ │\n'+
* '└────┘\n'
*
* (2,2) => '┌┐\n'+
* '└┘\n'
*
* '┌──────────┐\n'+
* (12,3) => '│ │\n'+
* '└──────────┘\n'
*
*/
function getRectangleString(/* width, height */) {
throw new Error('Not implemented');
}
/**
* Encode specified string with ROT13 cipher
* See details: https://en.wikipedia.org/wiki/ROT13
*
* @param {string} str
* @return {string}
*
* @example
*
* 'hello' => 'uryyb'
* 'Why did the chicken cross the road?' => 'Jul qvq gur puvpxra pebff gur ebnq?'
* 'Gb trg gb gur bgure fvqr!' => 'To get to the other side!'
* 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
* => 'NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm'
*
*/
function encodeToRot13(/* str */) {
throw new Error('Not implemented');
}
/**
* Returns true if the value is string; otherwise false.
* @param {string} value
* @return {boolean}
*
* @example
* isString() => false
* isString(null) => false
* isString([]) => false
* isString({}) => false
* isString('test') => true
* isString(new String('test')) => true
*/
function isString(/* value */) {
throw new Error('Not implemented');
}
/**
* Returns playid card id.
*
* Playing cards inittial deck inclides the cards in the following order:
*
* 'A♣','2♣','3♣','4♣','5♣','6♣','7♣','8♣','9♣','10♣','J♣','Q♣','K♣',
* 'A♦','2♦','3♦','4♦','5♦','6♦','7♦','8♦','9♦','10♦','J♦','Q♦','K♦',
* 'A♥','2♥','3♥','4♥','5♥','6♥','7♥','8♥','9♥','10♥','J♥','Q♥','K♥',
* 'A♠','2♠','3♠','4♠','5♠','6♠','7♠','8♠','9♠','10♠','J♠','Q♠','K♠'
*
* (see https://en.wikipedia.org/wiki/Standard_52-card_deck)
* Function returns the zero-based index of specified card in the initial deck above.
*
* @param {string} value
* @return {number}
*
* @example
* 'A♣' => 0
* '2♣' => 1
* '3♣' => 2
* ...
* 'Q♠' => 50
* 'K♠' => 51
*/
function getCardId(/* value */) {
throw new Error('Not implemented');
}
module.exports = {
concatenateStrings,
getStringLength,
getStringFromTemplate,
extractNameFromTemplate,
getFirstChar,
removeLeadingAndTrailingWhitespaces,
repeatString,
removeFirstOccurrences,
unbracketTag,
convertToUpperCase,
extractEmails,
getRectangleString,
encodeToRot13,
isString,
getCardId,
};