jncodes / justify-text

Distribute text evenly between specified margins.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Challenge:

Write a function that takes in a string and prints it to the console so that each line is 30 characters long (including spaces and punctuation).

  • Words cannot wrap lines and each line must end with a word
  • Spaces on the same line should be spread out evenly between words (+/- 1 character)

Example string:

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

Solution:

alt text

About

Distribute text evenly between specified margins.


Languages

Language:JavaScript 100.0%