*Best Practice* creating and writing the html with JS

I am tasked with consuming json, sorting it, processing it and writing a table of records to the window, and I have to do it with via vanilla JS. So basically index.html with script=app.js that does all the work.

I’m new to JS (but not to programming) and I need to do this in a way that doesn’t expose me as a complete novice :slight_smile:

I’ve searched the web, but couldn’t pin this down.

Naively, I have two options:

I can build up a giant string of html and document.write to it, or I can add and edit dom elements.

JS doesn’t have a built in string building facility (or does it?) so I’m leaning towards direct dom editing. Is my thinking on track? Anything I should keep in mind when doing that?

Will really appreciate any help I can get.

General rule of thumb: take the option that involves the fewest DOM changes