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

Confused as to where I'm going wrong... all my code is displaying in the document?

var randomNumber = randomNumbers (16, 72);

function randomNumbers(a, b) {
 return Math.floor(Math.random() * (6 - 1 + 1)) + 1; 
}

document.write(randomNumbers);

2 Answers

Hey Josh,

randomNumbers() is a function. If you just document.write() a function, you'll just see the innards of your function spit out on the screen. What you want to do is spit out the return value of randomNumbers. You do that be calling randomNumbers, like so:

function randomNumbers(a, b) {
  return Math.floor(Math.random() * (6 - 1 + 1)) + 1; 
}

document.write(randomNumbers());

Thanks Mikis!