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

JavaScript

Dice 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?

https://repl.it/Gmrr/1

1 Answer

Hi 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.

Actually 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!