Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialsaul bard
7,581 PointsWhy isn't my balance changing?
Can someone please have a look at why my balance isn't changing? I made it so that the due date is set in the past. I also added an event listener so when I click on the page it runs chargeFines() but the balance of the patron is not changing.
Thanks
1 Answer
Steven Parker
231,269 PointsThe "filter" function in "chargeFines" does not return a value, so the filtered list ("latePatrons") is always empty.
You can return a value explicitly with a "return" statement, or you can use the abbreviated form of arrow function and the result of evaluating the expression will be implicitly returned:
// this filter function does not return anything
patron => { (patron.currentBook !==null && patron.currentBook.dueDate < today) }
// but this one will
patron => { return (patron.currentBook !==null && patron.currentBook.dueDate < today); }
// and so will this one
patron => (patron.currentBook !==null && patron.currentBook.dueDate < today)