Как добавить новую строку в <div> Javascript?
Как добавить абзац в в Javascript?
var pElement = document.createElement("div");
var solveBlock = document.getElementById("solveBlock");
pElement.className = "steps"
let randint = 100;
let answer = 0;
while (randint > 0){
pElement.textContent += '\n';
pElement.textContent += randint + ' : 2 = ' + Math.floor(randint / 2) + ' целых, ' + randint % 2 + ' в остатке';
answer = randint % 2 + answer
randint = Math.floor(randint / 2);
}
solveBlock.appendChild(pElement);
<div id="solveBlock">
</div>
Источник: Stack Overflow на русском