title: Join function in JavaScript with separator not showing at the end for arrays with unknown number of elements
body: <p>I am new to JavaScript and I have encountered a little problem while using the join function. I have an array with an unknown number of elements and I want to print it with separators between each two elements using join. I want to get something like this: <code>a/b/c/d</code> with '/' being the separator. The problem is that I get one last separator at the end, like this: <code>a/b/c/d/</code>. How can I get rid of this?<br>
  Here is my code:  </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 makePath;
  
  function makePath(separator) {
    let comp = []
    return function(element) {
      comp.push(element)
      return comp.join(separator)
    }
  }
  
  var main = function() {
    var p1 = makePath("/");
    p1("One");
    p1("Two");
    p1("Three");
  
    window.console.log("p1:" + p1());
  }
  
  main()</code></pre>
  </div>
  </div>
  </p>