You make a good point. And, yes, you're on track. I noticed a couple of things while thinking about your answer. Try the following replace logic. ["a","b"].join("-").replace(/(^-)|(-$)/g,'') --> "a-b"["","b"].join("-").replace(/(^-)|(-$)/g,'') --> "b"["a",""].join("-").replace(/(^-)|(-$)/g,'') --> "...