title: String to array then remove last element
body: <p>I have the strings below and I am trying to remove the last directory from them but I cant seem to get the grasp of it.</p>
  
  <p>JavaScript</p>
  
  <pre><code>var x = path.split("/")
  alert(path +' = ' +x.slice(0, -1));
  </code></pre>
  
  <p>Expected Result</p>
  
  <pre><code>/foo/bar/ = /foo/
  /bar/foo/ = /bar/
  /bar/foo/moo/ = /bar/foo/
  </code></pre>