Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRyan Belshaw-Weir
5,721 PointsIs return this.unusedTokens.shift() the same as return this.unusedTokens[0]?
I was wondering is there any difference between the Is return this.unusedTokens.shift() and this.unusedTokens[0]?
2 Answers
Steven Parker
231,236 PointsBoth of those expressions will return the first token, but when you use "shift" it removes it from the array.
Ryan Belshaw-Weir
5,721 PointsThat's what I thought but if I log game.activePlayer.unusedTokens to the console before and after the shift expression it is the same. Why is that?
Steven Parker
231,236 PointsPerhaps "this" is something other than "game.activePlayer", and you're looking at the wrong list.
If you still have trouble, make a snapshot of your workspace and post the link to it here.