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 The Solution

Christian Pereira
Christian Pereira
1,221 Points

Browser not adding the third argument in my function

Here's my full code but the specific issue involves the areaPrism function.

function areaRectangle(width, height) {
  if (isNaN(width) || isNaN(height)) {
    throw new Error('Both agruments need to be a number!')
  }
  return width * height;
}

function areaPrism(width, height, length) {
  if (isNaN(width) || isNaN(height) || isNaN(length)) {
    throw new Error('All agruments need to be a number!')
  }
  return width * height * length;
}
console.log(areaRectangle(2,5));
console.log(areaRectangle(4, 5, 6));

When I go into the browser and the code runs, I check the console and it outputs 20. I'll change the numbers and the same thing happens, it for some reason won't add my third number. What am I doing wrong?

1 Answer

In your console.log statements you aren't calling areaPrism(). You are calling areaRectangle() twice.