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 trial

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

Amy Preci
PLUS
Amy Preci
Courses Plus Student 5,528 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
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Bella Bradbury
Front End Web Development Techdegree Graduate 32,790 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
229,732 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.

Cas F
seal-mask
.a{fill-rule:evenodd;}techdegree
Cas F
Full Stack JavaScript Techdegree Student 21,170 Points

This fixed the problem for me. Just remove the "toFixed" from your method chain and the challenge accepts your solution.