I am making a Random number generator and it generated by using timestamp mixed with random alphabet letters. below is my code for generating a random number
var ts = String(new Date().getTime()),
i = 0,
out = '';
for (i = 0; i < ts.length; i += 3) {
out += Number(ts.substr(i, 2)).toString(36);
}
var ans = Math.random().toString(15).slice(5);
var para = (out + ans);
var chassis = (para.slice(0, 15));
console.log(chassis);
document.getElementById("output").innerHTML = chassis;
// OUTPUT is like this:- g81x292daaba1ba
with this code generate one unique number every time when i was click on a button. But now I want to make a text field where i can write how many unique random number i want to generate. For Example if I write 10 on the text field then I want 10 unique random number to be generated. This is the code i was trying but it gives me undefined output
const unit = document.getElementById('unit');
var ts = String(new Date().getTime()),
i = 0,
out = '';
for( j=0; j<=unit;j++) //unit is the id of input type="text"
{
for (i = 0; i < ts.length; i += 3) {
out += Number(ts.substr(i, 2)).toString(36);
var ans = Math.random().toString(15).slice(5);
var para = (out + ans);
var chassis = (para.slice(0, 15));
console.log(chassis);
document.getElementById("output").innerHTML = chassis;
}