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 trialJason Smith
145 PointsWhy is this teacher showing us old 1998 programming?
I downloaded the following files for this video, the code did not match, it was very confusing on the old coding techniques used in the video until I had to do further research on the PROPER ways on making this dice to roll and get the number. Please review the proper code.
<div class="contentHolder"></div>
<button type="button" class="myButton">Roll Dice</button>
* {
font-family: Helvetica, Arial, sans-serif;
text-align: center;
}
button {
background-color: rgb(82, 186, 179);
border-radius: 6px;
border: none;
color: rgb(255, 255, 255);
padding: 10px;
text-transform: uppercase;
width: 200px;
cursor: pointer;
}
.contentHolder {
height: 100px;
width: 100px;
padding: 50px;
margin: 50px auto;
border: 1px solid gray;
border-radius: 10px;
font-size:80px;
}
function Dice(){
this.sides = 6;
}
Dice.prototype.roll = function (){
var randomNumber = Math.floor(Math.random() * this.sides) + 1;
return randomNumber;
}
Dice.prototype.printNumber = function (){
var contentHolder = document.querySelector(".contentHolder");
contentHolder.innerHTML = this.roll();
}
var myDice = new Dice();
var button = document.querySelector(".myButton");
button.addEventListener("click", myDice.printNumber.bind(myDice), false);
1 Answer
Steven Parker
231,264 PointsSince there's no subject tags or links to the course or teachers in your post, the staff may not see it.
To make sure any issues with the material reach the staff, try writing directly to Treehouse Support.