-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcards.js.txt
17 lines (12 loc) · 1.13 KB
/
cards.js.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
CARDS.JS
---
I chose JavaScript/React for this exercise because:
- My most recent projects are React, so it's fresh in my mind
- The simplicity of working with arrays in JavaScript
- React (create-react-app) makes building a UI easy, and I figured you'd (the user) want to see a print out of the deck, verify it's being shuffled, and a print out of the "hands" being dealt.
* essentially a component is a class
* create-react-app comes with Jest to run tests
CONSIDERATIONS
* The description doesn't mention how many "players" or "hands" need to be dealt. It just says deal one card and potentially all the cards. I added a setting to specify number of hands to deal.
* Knuth-Shuffle (https://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array). Used this initially, rather than re-inventing the wheel, as it was easy to install via npm. However, I decided to write my own function based on this approach (and this egghead.io video I watched: https://egghead.io/lessons/typescript-create-random-integers-in-a-given-range)
* Using nested-loops is fine, as the max iterations is 52, so there are no performance worries.