Lodash _.padEnd() method is used to pad a string with another string until it reaches the given length. The padding is applied from the right end of the string. Padding characters are truncated if they exceed the length.
Syntax:
_.padEnd( [string = ''], [length = 0], [chars = ' '] );
Parameters:
- string: This parameter holds the string to the pad.
- length: This parameter holds the length of the pad.
- chars: This parameter holds the string used as padding.
Return Value:
This method returns the padded string.
Example 1: In this example, we are adding the given string at the end of the given original string with the help of the lodash _.padEnd() method.
Javascript
const _ = require( "lodash" );
console.log(_.padEnd( 'GFG' , 5));
console.log(_.padEnd( '1234' , 6, '#' ));
|
Output:
'GFG '
'1234##'
Example 2: In this example, we are adding the given string at the end of the given original string with the help of the lodash _.padEnd() method.
Javascript
const _ = require( "lodash" );
console.log(_.padEnd( 'GFG' , 6, '-' ));
console.log(_.padEnd( '1234' , 3, '#' ));
|
Output:
'GFG---'
'1234'
Last Updated :
03 Nov, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...