Typescript Count Array Javascript Iteration