lundi 8 juin 2015

Javascript random array test data

How to pick a random value for each name i generate? Starting code

Max = 25;
var pers = ['Mike', 'Ole', 'Tulle'];
var persons = [];
var person = {};
for(i = 0; i<Max; i++){
persons.push(pers);
}
persons.name = [Math.floor(Math.random() * persons.length)];

It should return an array of 25 or 100 or whatever, generated test data.It just returns all the names random times right now.




Aucun commentaire:

Enregistrer un commentaire