I am currently fetching NBA game data from an API using Javascript, and I am facing a challenge in manipulating it. Each game entry is stored as its own object, with information presented in the following format:
Date: "Nov 7, 2014"
Opponent: "@ Charlotte"
Result: "L"
Score: "122-119"
Spread: "+1.5"
Depending on whether the team is playing home or away, there is either a "@" or a "vs" preceding the opponent's name for that specific game. My goal is to remove this prefix so that the "Opponent" key only contains the name of the opponent without any unnecessary characters.
I attempted to achieve this by using
gameLog[i].Opponent = (gameLog[i].Opponent.split(" ").pop
to eliminate any characters before the space, but unfortunately, this approach messes up the data when dealing with team names containing spaces like "New York" or "Los Angeles".