title: Get all string in one variable after space in javascript
body: <p>what i am doing</p>
  
  <p>for example i have a name</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 nameofuser = 'John Constantine vayo';
      var values = nameofuser.split(" ");
      var f_name = values[0];
      var l_name = nameofuser.substr(nameofuser.indexOf(' ') + 1);
      console.log(f_name);
      console.log(l_name);</code></pre>
  </div>
  </div>
  </p>
  
  <p>it is working fine when user entering his last name and other title or so on, it is all going in l_name but when a user enterned only first name like only 'John' then l_name is also populated with 'john' :(, </p>
  
  <p>i want IF a user type last name and so on then only l_name should be populated.</p>
  
  <p>if user type only first name then only f_name with first name should be populated</p>