Pads the string with the padWith so that it appears in the center of a new string with the provided length.
padWith
const str = "Hello, World!";const padded = centerPad(str, str.length + 4);console.log(padded); // ' Hello, World! ' Copy
const str = "Hello, World!";const padded = centerPad(str, str.length + 4);console.log(padded); // ' Hello, World! '
Pads the string with the
padWith
so that it appears in the center of a new string with the provided length.