Apply new format to snippets and template
This commit is contained in:
@@ -5,8 +5,8 @@ tags: string,beginner
|
||||
|
||||
Indents each line in the provided string.
|
||||
|
||||
Use `String.replace` and a regular expression to add the character specified by `indent` `count` times at the start of each line.
|
||||
Omit the third parameter, `indent`, to use a default indentation character of `' '`.
|
||||
- Use `String.replace` and a regular expression to add the character specified by `indent` `count` times at the start of each line.
|
||||
- Omit the third parameter, `indent`, to use a default indentation character of `' '`.
|
||||
|
||||
```js
|
||||
const indentString = (str, count, indent = ' ') => str.replace(/^/gm, indent.repeat(count));
|
||||
|
||||
Reference in New Issue
Block a user