Typescript Count Elements In Array Javascript Iterations