Logo

Programming-Idioms

History of Idiom 214 > diff from v11 to v12

Edit summary for version 12 by Vaporox:
New JS implementation by user [Vaporox]

Version 11

2020-04-15, 21:30:41

Version 12

2020-08-10, 12:40:59

Idiom #214 Pad string on the right

Append extra character c at the end of string s to make sure its length is at least m.
The length is the number of characters, not the number of bytes.

Idiom #214 Pad string on the right

Append extra character c at the end of string s to make sure its length is at least m.
The length is the number of characters, not the number of bytes.

Variables
c,s,m
Code
const padded = s.padEnd(m, c);
Doc URL
https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd