Нужно что бы метод draw() удалял последний елемент масива cards.
function deckBuilder() {
const values = [ "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", ];
const suits = ["Hearts", "Diamonds", "Spades", "Clubs"];
const cards = [];
for (let s = 0; s < suits.length; s++) {
for (let v = 0; v < values.length; v++) {
const value = values[v];
const suit = suits[s];
cards.push({ value, suit });
}
}
return cards;
}
const deckN = deckBuilder();
class Deck {
constructor() {
this.cards = deckN;
this.count = this.cards.length;
}
shuffle() {
let location1, location2, tmp;
for (let i = 0; i < 1000; i++) {
location1 = Math.floor((Math.random() * this.cards.length));
location2 = Math.floor((Math.random() * this.cards.length));
tmp = this.cards[location1];
this.cards[location1] = this.cards[location2];
this.cards[location2] = tmp;
}
}
draw() {
return this.cards.pop();
}
}
let gameBoard = new Deck();
gameBoard.shuffle();
gameBoard.draw();
console.log(gameBoard.count);