After reading in data from a csv, I have an array of objects like so,
myData = [
{country: "USA", amount: " $1,000,000.00"},
{country: "Canada", amount: " 1,500,000.00"},
{country: "Mexico", amount: " $2,000,000" }
]
I am trying to create a variable called total
that sums up the “amount” column. However, there is leading white space and the dollar signs (essentially it is being interpreted as a string).
Is there a way to convert the amount column to a number so that it can be summed?