How to split text into lines of equal number of characters?

  • 0
    And so, there is text as a line (long line)

    you need to divide it into equal + - lines (by the number of characters, including spaces), while you cannot divide words, how can this be implemented?

    Let the number of characters in the line be called the median, the error of characters is 5, that is, the line can be length from the median - 5 to the median + 5
    JavaScript Noah Ferguson, Apr 16, 2020

  • 1 Answers
  • 0
    You split the string by spaces, then you go through the array with reductions, creating an array of strings. You add words to the line of the array until the length is out of bounds, then you push a new line and continue until the full pass.
    Aurora Snyder

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!