I'm trying to add all expenses that match a certain category in an expense tracker app.
ForEach(fetchRequestExpense) { (expenselog: Expenses) in
if category == expenselog.expenseCategory{
var sum += expenselog.expenseCost
}
}
return sum
}
This won't compile. Should I be using a for loop for this type of calculation?