JavaScript JavaScript Loops, Arrays and Objects Tracking Multiple Items with Arrays Useful Array Methods

Sam Allen
Sam Allen
7,171 Points

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
174,115 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
174,115 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
174,115 Points

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