Hello, and nicely done!
update: redid this as with @maury91's fixed code below you can in fact use just
reduce's function needs to return something, and you can't just return an
if statement as that itself has no return value.
snazzy totalCost with just reduce
// updated after @maury91 figured it out below, and
// the solution just needed a quick fix (see below) to get it to work
(sum, curr) => sum + (curr.isRacing && curr.entryFee) , 0);
Carlos, one of the course devs here, came up with this. It is a bit tricky.
snazzy reduce and filter totalCost
return this.races.filter((r) => r.isRacing)
.reduce((prev, curr) => prev + curr.entryFee, 0);