I am just getting started in programming and ran into this issue. The answers posted on the forum don't really help me out so here goes my question. I am trying to create a function that generates four random numbers between 1-12. Once the numbers are generated, they are assigned to a individual variable.
var gem1;
var gem2;
var gem3;
var gem4;
function updateGem() {
gem1 = Math.floor(Math.random() * 12 + 1);
gem2 = Math.floor(Math.random() * 12 + 1);
gem3 = Math.floor(Math.random() * 12 + 1);
gem4 = Math.floor(Math.random() * 12 + 1);
}
As you can see sometimes the numbers generated are matching, which is not what I need. I need every var to have it's own unique number.
The value of gem 1 is 8
The value of gem 2 is 9
The value of gem 3 is 9
The value of gem 4 is 8