Javascript Array Push Inside Foreach Not Working