Solved the infinite loop caused by the string with no spaces by stopping the loop in such case
Solved the infinite loop caused by the string with no spaces by stopping the loop in such case

romenrg/kata-word-wrap-js