Open In App

Lodash _.padEnd() Method

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:

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.




// Requiring the lodash library 
const _ = require("lodash");
 
// Use of _.padEnd() method
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.




// Requiring the lodash library 
const _ = require("lodash");
 
// Use of _.padEnd() method
console.log(_.padEnd('GFG', 6, '-'));
console.log(_.padEnd('1234', 3, '#'));

Output:

'GFG---'
'1234'
Article Tags :