Typescript Iterate Through Array Javascript Function