Typescript Array Distinct Javascript Substring Function Of String