I created an id for the variable I wanted to use but can't find how to insert it in the p element. When I try this I get "Uncaught type error: cannot set property of 'innerHTML' of null(...).
var str = array.toString();
document.getElementById('variable').innerHTML = str;
<p> Start of sentence <id = "variable" />, end of sentence</p>
answer to this question is to use span tag.