The function below takes a multiline string, splits the string line by line, and optionally adds your desired number of spaces before and after each line.
Most of the parameters of the Javascript function are optional with default values for the purpose of making this function as flexible as possible, such as the padding at the beginning and end of the string. For this reason, several examples of ways of using the function to split a string and add padding will be shown below.
Split Above Text into Line by Line Array and Trim ...