Logo

Programming-Idioms

History of Idiom 214 > diff from v12 to v13

Edit summary for version 13 by programming-idioms.org:
[JS] Implicitly want to update variable s

Version 12

2020-08-10, 12:40:59

Version 13

2020-08-11, 14:41:16

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
Variables
c,s,m
Code
const padded = s.padEnd(m, c);
Code
s = s.padEnd(m, c);
Doc URL
https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd
Doc URL
https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd