It takes the length as a parameter so that it makes sure that after concatenation the length of the resulted string should match with provided length.
It takes a string as a second parameter to concatenate with the first string.
In the following example, the method str.padEnd() has taken a length and a second-string as its parameters. It will concatenate the second string based on the length given by the user.
<html> <body> <script> var str = "Hello"; document.write(str.padEnd(23," glad to meet you")); document.write("</br>"); document.write(str.padEnd(37," glad to meet you")); </script> </body> </html>
Hello glad to meet you Hello glad to meet you glad to meet y
If the first string is greater than the length provided then no concatenation takes place.
In the following example, the initially given string is more than the length provided. So no changes will occur on the first string and the string itself will be displayed as the output.
<html> <body> <script> var str = "Hello pleasure to meet you"; document.write(str.padEnd(15," glad to meet you")); </script> </body> </html>
Hello pleasure to meet you