SHARE
TWEET

Untitled




Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- import cards from './GameResources'
- const generateBoard = () => {
- let board = []
- for (let i = 0; i < cards.length * 2; i++) {
- let randomCard
- do {
- randomCard = cards[Math.floor(Math.random() * cards.length)]
- } while (
- board.filter(element => element.type === randomCard.type).length >= 2
- )
- board.push(Object.assign({}, randomCard))
- }
- return board
- }
- export default generateBoard
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.