I am making a card-flip game in javascript, and would like to be able to pull out different sets of cards. In the data.js file I have 2 arrays, one for cards in one language, and one for cards in another:
const cardsItalian = [{
name: "Cane Bianco",
image: "cane.png",
id: "cane"
},
{
name: "Cane Bianco",
image: "cane2.png",
id: "cane2"
},
There is also a const cardsSpanish.
In the game.js file, I can call the data from data.js, and I have the following at the bottom:
const startGame = (cards, level) => {
// reset game variables
gameStarted = false;
moves = 0;
matches = 0;
setLevel(level);
// reset HTML
$('#game-board').empty();
$(".clock").text('0:00');
$("#moves").text('0');
$('#winModal').hide();
// Get cards and start the game
let cardArray = makeCardArray(cardsItalian, level);
shuffle(cardArray);
displayCards(cardArray);
};
This code allows me to take the cards from cardsItalian array, or I can change it to cardsSpanish, however I am struggling to figure out how to do it for one or the other based on the user's selection! Driving me nuts.
I'm sure I could add a condition but I'm not sure where