Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
218,692 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
218,692 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
218,692 Points

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