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 trialLeo Marco Corpuz
18,975 PointsCode written exactly like in the video and it still doesn't work?
function DiceRoll(side) { this.sides= side; this.roll=function(){ var randomNumber = Math.floor(Math.random() * this.sides) + 1; return randomNumber; }; //end random number function }; //end dice function
var dice= new DiceRoll(6);
1 Answer
Steven Parker
231,269 PointsThe "roll" function works great! But perhaps you're talking about what happens when you press the "roll dice" button on the screen? That's a result of what's on line 9 of "ui.js":
var result = 1;
As you can see, it will always show a "1". But if you wanted to show a dice roll instead, you could replace that line:
var result = dice.roll();
Great idea to post the snapshot, it made it simple to find the issue even though it was in different code.
Leo Marco Corpuz
18,975 PointsThanks!
Barry Allen Jr
774 PointsI had the same problem. Thx a lot Steven Parker !
Leo Marco Corpuz
18,975 PointsLeo Marco Corpuz
18,975 Pointshttps://w.trhou.se/bhgd9yxjg4