I started to work on my memory mini game, but stopped right after start :( For
loop is not working for me.
My code:
const game = {
...
shuffledCards: [],
startGame: () => {
...
// clear variables
this.shuffledCards = [];
for (let i = 0; i < this.cardsCount; i++) {
this.shuffledCards.push(Math.floor(i/2));
}
}
}
I want to generate an array which looks like this[0, 0, 1, 1, 2, 2...]
, but that for
loop returns an empty array. Do you know why? When I try to change variables from this
to normal ones and paste the code into browser, it works...