Convert Array Into Hashmap Javascript Interview