lundi 25 juin 2018

How do you not get repeating numbers from math.floor?

My goal is to make these gems all have different values from 1-10

If you could help me out while still using mathfloor I would appreciate that as well

//Variables
var emGem = 0;
var ruGem = 0;
var diGem = 0;
var saGem = 0;
var possibleGem = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

//Initiate scores
emGem = possibleGem[Math.floor(Math.random() * possibleGem.length)];
ruGem = possibleGem[Math.floor(Math.random() * possibleGem.length)];
diGem = possibleGem[Math.floor(Math.random() * possibleGem.length)];
saGem = possibleGem[Math.floor(Math.random() * possibleGem.length)];

//Debug
console.log(emGem);
console.log(ruGem);
console.log(diGem);
console.log(saGem);
console.log(randomNumber);



Aucun commentaire:

Enregistrer un commentaire