title: Increase the string by spaces to a specified width
body: <p>I can add only one space after <code>arr[i]</code>, but i need spaces to depend on the <code>.length</code> of the string </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var addSpace = function(str, maxLength) {
    if (maxLength &lt; str.length) {
      return str;
    } else if (maxLength &gt; str.length) {
      var arr = str.split(" ");
      for (var i = 0; i &lt; arr.length; i++) {
        arr[i] = arr[i] + " ";
      }
      return arr.join(" ");
    }
  }
  console.log(addSpace("This is my string", 30));</code></pre>
  </div>
  </div>
  </p>