<!DOCTYPE HTML>
<html>
<body>
<script>
let ul = document.createElement('ul');
document.body.append(ul);
while (true) {
let data = prompt("Enter the text for the list item", "");
if (!data) {
break;
}
let li = document.createElement('li');
li.textContent = data;
ul.append(li);
}
</script>
</body>
</html>
I know prompt will block current Thread, but ul.append(li) is executed after a user respond the prompt, before the next prompt begin.
Environment: Google Chrome Version 96.0.4664.45 (Official Build) (64-bit)