Typescript Iterate Through Array Javascript Splice Method