added function joinPathElements() to javascript