Function is not pulling up the entire array value in typescript