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
Willie Suggs
Courses Plus Student 5,879 Pointswhy isn't this code working?
function callRandom() { var randomNumber = Math.floor( Math.random() * 6) + 1); alert(randomNumber); }
callRandom();
3 Answers
Clayton Perszyk
Treehouse Moderator 49,057 PointsYou're missing a parenthesis before Math.random; add that and it will work.
you might also want to reformat your code like this, so it's easier to read:
function callRandom() {
var randomNumber = Math.floor( (Math.random() * 6) + 1);
alert(randomNumber);
}
callRandom();
Willie Suggs
Courses Plus Student 5,879 Pointsi feel stupid, lol! how didn't i see that, thanks.
Clayton Perszyk
Treehouse Moderator 49,057 Pointsno worries. it happens to everyone.
Willie Suggs
Courses Plus Student 5,879 Points:)