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 trial
Amrit Pandey
17,595 PointsDice Roll program using method prototype
I have called the diceRollProgram twice with prototype method, the result of two must be same but I am getting different result! What is the problem?
1 Answer
Ryan S
27,276 PointsHi Amrit,
I'm not quite sure what you are asking. Just looking at your code, you are only calling the roll method once and assigning it to "rollTheDice."
If you mean that you are running the script twice, then the result logged to the console will always be a random number. So it may or may not be the same as the previous run. It seems to be working exactly as it should.
Another thing to point out is that you've provided a function argument called "sides" but you don't actually use it in your function. Instead you have hard coded the number 6, so your dice will always have 6 sides no matter what.
Hope this helps.
Amrit Pandey
17,595 PointsAmrit Pandey
17,595 PointsActually Andrew Chawlky made program like that and he always gets true, I did'nt copied him but made my own version so actually what you are telling is right thanks!