When I run this code in JSbin the cardList "card" object contains random numbers as expected. But when I run it locally the outcome is that that "cards" are all set to "0". I've spent a day trying to figure out why. Any ideas?
By the way the code runs as expected locally if I change the "max" variable in the getRandomInt function to an actual number (getRandomInt comes from here).
var cardList = [];
var randomCardlist = []
var max = 9;
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function GetRandomCards(max) {
var randomCardlist = [];
for (var i = 0; i <= 16; i++) {
var x = getRandomInt(0, max);
randomCardlist.push(x);
}
randomPositioning(randomCardlist)
}
GetRandomCards(max);
function randomPositioning(randomCardlist) {
for (var y = 0; y <= 16; y++) {
cardList.push({
type: "image",
position: y,
card: randomCardlist[y]
});
}
console.log(cardList);
}