diff --git a/README.md b/README.md
index f4b8d1642..ab1b54665 100644
--- a/README.md
+++ b/README.md
@@ -221,6 +221,7 @@
* [`repeatString`](#repeatstring)
* [`reverseString`](#reversestring)
* [`sortCharactersInString`](#sortcharactersinstring)
+* [`splitLines`](#splitlines)
* [`toCamelCase`](#tocamelcase)
* [`toKebabCase`](#tokebabcase)
* [`toSnakeCase`](#tosnakecase)
@@ -2574,55 +2575,6 @@ Use `Math.max()` combined with the spread operator (`...`) to get the maximum va
```js
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
const max = (...arr) => Math.max(...[].concat(...arr);
```
@@ -3455,6 +3407,28 @@ sortCharactersInString('cabbage'); // 'aabbceg'
[⬆ Back to top](#table-of-contents)
+### splitLines
+
+Splits a multiline string into an array of lines.
+
+Use `String.split()` and a regular expression to match line breaks and create an array.
+
+```js
+const splitLines = str => str.split(/\r?\n/);
+```
+
+Examples
+
+```js
+splitLines('This\nis a\nmultiline\nstring.\n'); // ['This', 'is a', 'multiline', 'string' , '']
+```
+
+
[⬆ Back to top](#table-of-contents)
+
+
### toCamelCase
Converts a string to camelcase.
diff --git a/docs/index.html b/docs/index.html
index 646106e90..907f4d132 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -242,6 +242,7 @@
repeatString
reverseString
sortCharactersInString
+splitLines
toCamelCase
toKebabCase
toSnakeCase
@@ -1217,55 +1218,6 @@ lcm([1, 3, 4], 5); // 60
Use Math.max() combined with the spread operator (...) to get the maximum value in the array.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
const max = (...arr) => Math.max(...[].concat(...arr);
max([10, 1, 5]); // 10
@@ -1620,6 +1572,13 @@ Combine characters to get a string using join('').
sortCharactersInString('cabbage'); // 'aabbceg'
+Splits a multiline string into an array of lines.
+Use String.split() and a regular expression to match line breaks and create an array.
const splitLines = str => str.split(/\r?\n/);
+
+splitLines('This\nis a\nmultiline\nstring.\n'); // ['This', 'is a', 'multiline', 'string' , '']
+
Converts a string to camelcase.
Break the string into words and combine them capitalizing the first letter of each word. diff --git a/snippets/max.md b/snippets/max.md index c90c6d655..7c09c9725 100644 --- a/snippets/max.md +++ b/snippets/max.md @@ -6,6 +6,7 @@ Use `Math.max()` combined with the spread operator (`...`) to get the maximum va ```js + const max = (...arr) => Math.max(...[].concat(...arr); ```