I modified Rinto's answer just for those who don't want to use the prompt method and just want to see the program print prime numbers . its working
for (n = 0; n < 100; n++) {
var x = 1;
if (n == 0 || n == 1) x = 0;
for (i = 2; i < n; i++) {
if (n % i == 0) {
x = 0;
break;
}
}
if (x == 1) {
// if prime print the numbers
document.write(n);
} else {
// if not prime print the number do nothing
}
}