[javascript] TypeScript and array reduce function