Why doesn't this function return anything?

I’m practicing simple JS functions but don’t understand why this function doesn’t return area:

function rectangleArea(width, height) {
  let area = width * height;
  return area;
}
rectangleArea(5, 7)

Just tested it, it works fine. Maybe show more of you code?

1 Like

Hello @El_Escandalo :grinning:

This rectangleArea() function is working fine.

1 Like

@M-Michelini Thanks. That’s all the code. I have it in Codepen and when I click “run”, it produces nothing- neither an output nor an error. It should log to the console right? (it’s not logging to the console or the page)

you want console.log(rectangleArea(5, 7))

1 Like

Ok so the return function does not actually log to the console on its own?

That’s right, except return is a keyword not a function.

1 Like

You are correct, the return function is going to stop the function from executing and return a value from that function but it doesn’t log anything to the console.

1 Like