Javascript random text generate randomly


Javascript random text generate randomly
I want create javascript random script which makes random text which every text has assigned random integer to it. and everything will be separated by , i.e
es45d4dw 2, hrt54345 5, etc.
Every item should be generated at random different time from range. How can i do that?
var myVar = setInterval(myFunction, getRndInteger(1000, 10000));
function getRndInteger(min, max)
return Math.floor(Math.random() * (max - min + 1)) + min;
function myFunction()
var para = document.createElement("t");
var t = document.createTextNode(makeid());
para.appendChild(t);
document.body.appendChild(para);
function makeid()
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < 10; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
This code just generates text at state one interval.
– sherlok222
2 days ago
A bettet option is to just use a recursive
setTimeout
– Keith
2 days ago
setTimeout
I think there is too much content now. I should just paste full code and simple question What I want as result (trying to do)
– sherlok222
2 days ago
1 Answer
1
What you want to do is use setTimeout and recursion
var myVar = setTimeout(myFunction, getRndInteger(1000,10000));
function myFunction()
var para = document.createElement("p");
var t = document.createTextNode(makeid());
para.appendChild(t);
document.body.appendChild(para);
myVar = setTimeout(myFunction, getRndInteger(1000, 10000));
This way getRndInteger is reset with each calling.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
and what is your problem? what is not working?
– Lux
2 days ago