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


Hi, guys! Just found something interesting. The following works, but for there is no info show, no errors, but

function getRandomNumber( upper ) {
    var randomNumber = Math.floor( Math.random() * upper ) + 1; 
   return randomNumber;
console.log( getRandomNumber(6));
console.log( getRandomNumber(100));
console.log( getRandomNumber(655));
console.log( getRandomNumber(6888));

There are no errors, but the 200, does not show. I did fix the issue, when I realized I had put the console.log(getArea(10, 20)); in the wrong place. No errors, but no result. An issue with Chrome? Or just a thing with JS?

function getArea(width, length) {
var area = width * length;
return area;  
console.log(getArea(10, 20));  

Moderator edited: Markdown added so that code renders properly in the forums.

Steven Parker
Steven Parker
229,645 Points

Try putting your message after the title. The message got cut off after "but..."

1 Answer

Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

Hi there! You're doing great, and I applaud your willingness to play around with concepts you've learned. No, there are no errors and there is no output. Really, the problem here is the placement of your console.log(). Remember, once a function hits a return statement, it ceases execution. Also, your function is calling itself, which is called recursion and not really needed here. Simply moving the console.log() fixes this issue.

Take a look:

function getArea(width, length) {
var area = width * length;
return area;  // function will exit here

console.log(getArea(10,20));  // call the function passing in 10 and 20 and return the result which is then logged to the console

Hope this helps! :sparkles:

Thanks, Jennifer! :)