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 Introducing the Practice

how do you console.log function in this workshop

function areatri(height, width) { return height * width; console.log(areatri(5, 22)); }

this gave me an error but maybe i did it wrong area

i tried taking console.log outside of function

2 Answers

function areatri(height, width) { 
  return height * width; <-- anything after a return statement does not run
console.log(areatri(5, 22));  // I think you would probably replace return with console.log
} //and then call the function with the args outside the function
Stephen Karney
Stephen Karney
1,643 Points

You can either place all console.log statements at the end of the js file:

console.log(recArea(5, 22)); console.log(recVolume(4.5, 12.5, 17.4)); console.log(circArea(7.2)); console.log(sphereVolume(7.2));

or build them within the function:

function recArea(width, height) { console.log(width * height); }

For the purpose of this workshop, the latter is probably fine, however, you may want to keep the return statement within the function instead as good practice. In the future you may create a function that will need to be run in different spots and using return would allow some flexibility.