MCPcopy
hub / github.com/skygragon/leetcode-cli / padCenter

Function padCenter

lib/sprintf.js:19–23  ·  view source on GitHub ↗
(s, n, c)

Source from the content-addressed store, hash-verified

17}
18
19function padCenter(s, n, c) {
20 let k = Math.max(0, n - len(s));
21 let r = (k - k % 2) / 2, l = k - r;
22 return c.repeat(l) + s + c.repeat(r);
23}
24
25const tsprintf = function() {
26 const args = Array.from(arguments);

Callers 1

tsprintfFunction · 0.85

Calls 1

lenFunction · 0.85

Tested by

no test coverage detected