Im using this function to generate a random string
function makeid(size)
{
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for( var i=0; i < size; i++ )
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
I try to create an array with two times the same random value like:
var game = {
_id:makeid(24),
createdOn:new Date(),
id : _id
}
However the error shows _id is not defined. when I remove id:_id it is valid. Why is _id not defined at this moment, the decleration is above id:_id in the same scope right?