rpad (JavaScript)
Fills a string on the right.
Defined in
String (Standard - JavaScript)Syntax
rpad(ch:string, length:int) : string
Parameters | Description |
---|---|
ch |
One or more characters. This pattern is repeated until the length parameter is satisfied. |
length |
The "length" of the output string:
|
Return value | Description |
---|---|
string |
The output string. |
Examples
(1) This example returns[#Paris
Moscow Tokyo#]
.function p(stuff) {
stuff = stuff.lpad("[#", stuff.length() + 1);
stuff = stuff.rpad("#]", stuff.length() + 1);
return stuff
}
var cities = new String("Paris Moscow Tokyo");
return p(cities)
(2) This example returns
###Paris
Moscow Tokyo###
.function p(stuff) {
stuff = stuff.lpad("#", stuff.length() + 3);
stuff = stuff.rpad("#", stuff.length() + 3);
return stuff
}
var cities = new String("Paris Moscow Tokyo");
return p(cities)