Typescript Iterate Through Array Javascript Splice