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!

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 trial

JavaScript JavaScript Array Iteration Methods Combining Array Methods Combining filter() and reduce()

Amy Preci
Amy Preci
3,198 Points

Did anyone else get an error when adding .toFixed(2)?

Adding .toFixed(2) to the end of the reduce method gave an error: "filter and reduce methods have not been called yet." Why did it work for him in the video but not here when the two problems are almost the same?

Bella Bradbury
.a{fill-rule:evenodd;}techdegree seal-36
Bella Bradbury
Full Stack JavaScript Techdegree Graduate 25,264 Points

Please post your code so that we can see what’s happening and then help to troubleshoot! In the future, when posting via the "get help" button from a challenge, please make sure "Attach my code with this post" is checked.

1 Answer

Steven Parker
Steven Parker
224,848 Points

The challenge is expecting the result as a number, but toFixed converts the number into a string.

This was not an issue in the video, since no numeric evaluation was being performed and the the result was just being displayed on the console.