Returns a new string of a given length such that the beginning of the string is padded.
Install
Install all functions of strman
yarn add strman
or just the leftPad function
yarn add strman.leftpad
Usage
import { leftPad } from 'strman'
// OR
import leftPad from 'strman.leftpad'
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
String | The String! |
||
length |
Number | Max length of String. |
||
char |
Char |
<optional> |
' ' | Char to repeat. |
- Source:
Returns:
String pad.
- Type
- String
Example
const title = 'strman'
leftPad(title, 10, 0)
// => '0000strman'