Convert Array Into Hashmap Javascript Substring Indexof