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?
Steven Parker195,447 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.
I just added a break; in each conditional to get instant feedback.