test.html
Read-only. This is working scratch, not reference material — it may not compile, may not be correct, and will change without warning.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body id="body">
<p>Testing</p>
<script >
function addPara(paragraph) {
console.log("adding paragraph: " + paragraph);
let p = document.createElement("p");
p.innerText = paragraph;
document.getElementById("body").appendChild(p);
};
function test() {
["1", "2", "3", "4", "5", "6"].forEach((x, i) => setTimeout(() => addPara(x), i * 1000));
// setTimeout(() => {
// addPara("1");
// setTimeout(() => addPara("2"), 800);
// }, 800);
// setTimeout(() => addPara("1"), 200);
// setTimeout(() => addPara("2"), 200);
// setTimeout(() => addPara("3"), 200);
// setTimeout(() => addPara("4"), 600);
// setTimeout(() => addPara("5"), 600);
// setTimeout(() => addPara("6"), 600);
};
test();
</script>
</body>
</html>