Context: I'm learning Javascript and many of the practice codes use document.write(), however I've been reading that it should be avoided, however some things in JS have embedded document.write()
e.g.
var i = 1;
do {
document.write ("Cool");
i = i + 500;
} while (i <= 10);
Question: do you attempt to rewrite the loop with an alternative document.write() method (e.g. createELement or innerHTML), or do you simply do your best to avoid its use?
You would want to refactor the write() call to something else like appending to
innerTextorinnerHTML, or (better) creating an element and appending it as a child.