Skip to main content
6 events
when toggle format what by license comment
Feb 21, 2017 at 20:14 comment added mhodges @Robert Also, I wouldn't advise having a functions.js, if you separate into too many files, it becomes a dependency and scoping nightmare as the project grows, unless you set up something like requireJS or another script-loader. I think those functions would be just fine in the war.jsfile
Feb 21, 2017 at 20:14 comment added Robert I never thought of it that way.
Feb 21, 2017 at 20:11 comment added mhodges Well, if you think about dealing a stack of cards, they go in LIFO/FILO (last in, first out / first in, last out) order. Which is the definition of the data structure known as a stack in programming. So, if you are adding cards to an array that represents the player's deck of cards from index 0 --> n, they should come out in n --> 0 order to replicate the behavior of a physical stack of cards. Like I said, it doesn't really matter for this particular application, but it may be something that an employer looks at to see if you can make that connection and use the proper data structure.
Feb 21, 2017 at 20:07 vote accept Robert
Feb 21, 2017 at 20:05 comment added Robert I thought .pop() pulled the last element of an array. the player's current card should be the first element in the array, which is why I used .shift(). I did some reorganizing earlier and created a functions.js script that holds the PlayGame() and GameOver() functions as well as a couple more I made. I guess I should do another question later today or tomorrow to show everything I did. I never thought about initializing the arrays, thank you for that. Once again, thank you for your help and feedback.
Feb 21, 2017 at 19:57 history answered mhodges CC BY-SA 3.0