mercredi 22 avril 2015

Select 2 random objects from array [duplicate]

This question already has an answer here:

I have an array such as:

array=['circle','star','square','hexagon','triangle','polygon'];

I can get random object with

 var pointer = myObjects.length * Math.random();
 posX = canvas.width * Math.random();
 posY = canvas.height * Math.random();
 pointer = Math.floor(pointer);

But I want to use random 2 objects in this array.How can I do?




Aucun commentaire:

Enregistrer un commentaire