PLAYING CARDS DRAW ORDER PART I

Subscribers:
4,890
Published on ● Video Link: https://www.youtube.com/watch?v=qUweKl6B1tk



Duration: 4:39
18 views
1


Write a function accepting a deck of cards as argument, and returning the cards drawn following the procedure.

EXPLANATION CODE:
1)The draw function performs the following actions on an array deck as input

2)It calls the printDeck function twice, passing deck as an argument. The first call prints the deck using Unicode characters, while the second call prints the deck using regular characters.

3)It initializes an empty array called drawnCards to store the drawn cards.

4)It enters a while loop that continues as long as the length of deck is greater than 1.

5)Inside the loop, it removes the first card from deck using the shift method and adds it to the drawnCards array using the push method.

6) After removing the second card from the deck, it appends it to the end of the deck array using the push method.

7)Once the loop ends, it concatenates drawnCards with the remaining cards in deck and returns the result.

Contents:
0:00 - Reading
2:40 - Solving
3:35 - Explaining

#codewars #code #wars #javascript #game #playingcards #playing #cards #draw #order #programming #education #tutorial #computerscience #mathematics #games #permutation







Tags:
codewars
code
wars
tutorial
step by step
education
computer science
explanation
7kyu
algorithms
games
puzzles
javascript
javascript programming
playing cards draw order part 1
playing cards
playing
cards
draw
order
permutation
mathematics