This question already has an answer here:
- Picking 2 random elements from array 6 answers
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