I want to create random usernames. I use a list names and firstnames from a file and get one from each files randomly.
var nameList= fs.readFileSync("random-name/names.txt").toString().split("\n");
var name = nameList[Math.ceil(Math.random()*nameList.length)];
var firstnameList= fs.readFileSync("random-name/first-names.txt").toString().split("\n");
var firstname= firstnameList[Math.ceil(Math.random()*firstnameList.length)];
The problem appears when I want to concatenate them:
console.log( name);
console.log( firstname);
console.log( firstname+"-"+name);
outputs:
Brant
Jesselyn
-Brantyn
There is obviously no problem if I set the variable name and firstname statically.
Math.floorinstead ofMath.ceil