JSFiddle - React, Tailwind, and code Playground
JavaScript
function printPrimesBelow(n){
i=1;
str = "";
while(i!=n){
x=0;
for(j=1;j<i;j++){
if(i%j==0){
x++;
}
}
if(x==1){
str += i+",";
}
i++;
}
str = str.substr(0,str.length-1);
return str;
}
document.write(printPrimesBelow(50));