i have simple question, the following code show some button ("press") and ask the user "how old are you?" if the user answer number greater than 20, the code write to the page "nice". The question is in a loop so the code ask 7 times this question.
The issue ( my question) is : the "nice" appears AFTER the loop is finished, why? it is like some caching. why it does not appears when the command "document.writeln("nice") is execute?
This phenomenon is just when i run it from chrome, it does not happen in EDGE or IE. what can i set in CHROME that this kind of CACHING will not occur? thanks
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script>
function run()
{
var i = 1;
var x = 0;
while (i<8)
{
x = window.prompt(i+ " how old are you ");
if (x>20)
{
document.writeln("nice" + " " + i + "<br>");
}
i = i+1;
}
}
</script>
</head>
<body>
<input type="button" value="press" onclick="run()">
</body>
</html>