I think you've made it much more complicated than need be. Just select the td.goal
elements, and use .map()
to return an object to a new array with the values from the current goal.
var result = $("table.card tr[class^=section] td.goal").map(function(i, tr) {
var goal = $(this);
return {
value: parseInt(goal.text(), 10),
color:goal.prev().css('color') || '#000000'
};
}).toArray();