Answer the question
In order to leave comments, you need to log in
How to create a class correctly?
Hey guys. I was sent a test task with one of the best companies in my city for the position of Trainee JS Developer. The job involves creating a Bingo game.
The bottom line is this:
There are 3 inputs for
class Card, class Player...
) input'a
(если в input вводится число 2, то должно создаваться 2 объекта Player.)
? Answer the question
In order to leave comments, you need to log in
Let the inputs change only the values of this.playersCount , this.cardsCount and this.numbersCount .
You don't need any id for the players, let them just lie in the array. Create by clicking on the "create game" or "create cards" button:
class Game {
// some stuff
createGame() {
this.players = [];
for (let i = 0; i < this.playersCount; i++) {
const player = new Player({
name: `Player ${i}`,
cards: this.createCards()
});
this.players.push(player);
}
}
createCards() {
// some stuff
}
// some stuff
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question