Typescript Count Array Javascript Function Syntax