First off, we have no idea exactly what you are planning on doing, but that code has so many things wrong with it that it doesn't look like you thought about it before you started to write it.
1) Fix the indenting - it makes it a load easier to read and work out what is supposed to happen!
2) Your
if
condition is outside the loop, instead of inside - so it only gets executed after the loop is finished.
3) Your numbers aren't separated by anything, so even if they worked, you couldn't tell what values you generated.
4) You don't put the result string anywhere useful.
5) You don't call the function, so it never gets executed anyway!
Try this:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<div id="answer"></div>
<script>
function answer () {
var text = "" ;
var number;
for (var i = 1; i <= 100 ; i++) {
var number = Math.round((Math.random() *9998) + 1);
text += number ;
text += ", ";
if (i % 10 == 0){
text = text + "<br>";
}
}
document.getElementById("answer").innerHTML = text;
}
answer();
</script>
</body>
</html>