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 Loops, Arrays and Objects Tracking Multiple Items with Arrays Useful Array Methods

Is there any way to refactor this code for modern browsers?

I'm thinking that since most modern browsers execute a loop, then print to a window ... we could somehow use console.log instead of document.write to satisfy the browser's need to print a result, then store that as a variable ... no?

2 Answers

Steven Parker
Steven Parker
231,261 Points

A way to display the result immediately could be the "alert" function. The results will appear in a pop-up just like the prompt does.

But don't spend much time on this, you'll soon learn other ways to perform user interaction that use page elements designed for the purpose.

With all respect, it is now December 14th 2018, and the video has not been modified. https://teamtreehouse.com/library/useful-array-methods When can we expect the version that works?

Steven Parker
Steven Parker
231,261 Points

I can't speak for Treehouse, but I'd guess it's not a high priority since they've provided an explanation in the Teacher's notes and the issue doesn't impact the point of the lesson.

Steven Parker
Steven Parker
231,261 Points

Doesn't a "break" also end the loop and alter the outcome?