A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript/javascript-string-padend-method/ below:

JavaScript String padEnd() Method - GeeksforGeeks

JavaScript String padEnd() Method

Last Updated : 12 Jul, 2025

The padEnd() method in JavaScript 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.

Syntax:
string.padEnd( targetLength, padString );
Parameters:

This method accepts two parameters as mentioned above and described below:

Return Value:

It returns the final string that is padded with the given string of the given length. 

Example 1: This example uses the padEnd() method to pad strings into another string. 

JavaScript
// Function to implement  padEnd method
function padStrings() {
    // Input methods
    exString = "Hello";
    exString2 = "Geeks";

    // Implement padEnd methods to add symbols at end
    output = exString.padEnd(12, "$");
    output2 = exString2.padEnd(12, "Geeks");

    // Display output
    console.log(output);

    console.log(output2);
}
// Function call
padStrings()

Output
Hello$$$$$$$
GeeksGeeksGe

Example 2: This example uses the padEnd() method to pad numbers into another number. 

JavaScript
// Function to implement padEnd method
function padNumbers() {
    // Input numbers
    exNumber = 1234;
    exNumber2 = 99;

    // Implement padEnd 
    output = String(exNumber).padEnd(8, "0");
    output2 = String(exNumber2).padEnd(8, "**");

    // Display output number
    console.log(output);
    console.log(output2);
}

// Function call 
padNumbers()
Supported Browsers:

The browser supported by the padEnd() method are listed below:



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4