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

Joseph Lander
Full Stack JavaScript Techdegree Graduate 27,765 PointsforEach method vs for loop - return doesn't break from the function
This is more of a help to others than a question. I created very similar code to the given solution but I try and use forEach on arrays where possible. In this setup, I found out that while my code works for the two sets of grades given, if I add an invalid grade the return statement "can't complete calculation" doesn't break from the function.
With some research I found that forEach
can't break from the array and will continue through all the elements.
https://medium.com/@virtual_khan/javascript-foreach-a-return-will-not-exit-the-calling-function-cfbc6fa7b199
Jeremy Yochum
Front End Web Development Techdegree Graduate 16,023 PointsJeremy Yochum
Front End Web Development Techdegree Graduate 16,023 PointsThanks for that.