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 trialSam Allen
7,176 PointsIs 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
231,110 PointsA 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.
Aaron Gibson
Full Stack JavaScript Techdegree Graduate 20,426 PointsI just added a break; in each conditional to get instant feedback.
Steven Parker
231,110 PointsDoesn't a "break" also end the loop and alter the outcome?
Peter Hope
Courses Plus Student 5,849 PointsPeter Hope
Courses Plus Student 5,849 PointsWith 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
231,110 PointsSteven Parker
231,110 PointsI 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.