title: Javascript remove reduce or trim strings from a string or link
body: <p>I have this link/string:</p>
  <pre><code>https://link/to/a/file/filename.ext
  </code></pre>
  <p>My JS skills are now rusty and I need to trim the link from the last instance of <code>/</code> so that I could separate the directory and the file name (with the file extension attached to the file name).</p>
  <pre><code>var string = 'https://link/to/a/file/filename.ext';
  
  var directory = 'https://link/to/a/file/'; // should have a value of 'https://link/to/a/file' coming from var string
  var file = 'filename.ext'; // should have a value of 'filename.ext' coming from var string
  </code></pre>