FAQ: Functions - Return


This community-built FAQ covers the “Return” exercise from the lesson “Functions”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Web Development

Introduction To JavaScript

FAQs on the exercise Return

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!


Hi, guys!
I have a noob question here: Why does it print ‘undefined’ instead of ‘35’? Why is the ‘return’ needed?

function rectangleArea(width, height) {
let area = width * height
console.log(rectangleArea(5, 7)) // Prints undefined


This lesson is so wrong. lol. I believe the tasks are backwards. Why do I have to use the return keyword before declaring the variables, in this case numOfMonitors? The examples wasn’t like that.


As the theory of the lesson says, the computer did calculated the area but it is stored in memory, so we need to get it with the keyword Return, if you don’t, it says undefinded.


The exercise to this Return lesson should be like this and not otherwise:

function monitorCount(rows, columns) {
  const numOfMonitors = rows * columns;
  return numOfMonitors;


That’s how the example is shown, so please be consistent, because it get’s you stuck, or if it’s going to change, let us be aware of that with the theory, etc.


Shoquim thank you for pointing that out, this example was confusing as it was not like the ones before.

I think they changed it because in coding there is more than one way to do the same thing. So they were maybe trying to show you a different way.


Yeah, I was having trouble here couldn’t figure out what I was doing wrong. Initially I had this:

function monitorCount(rows, columns) {
const numOfMonitors = monitorCount(5,4);
   return rows * columns;

and it gave me a ReferenceError “numOfMonitors” is not defined. After googling this error, I found out that numOfMonitors in the above code was out of scope, so then I did this and it worked for me:

const numOfMonitors = monitorCount(5,4);
function monitorCount(rows, columns) {
   return rows * columns;

So, yes, I certainly think there was more than one way to approach this lesson. So far this has been the only one to throw me off though. Good luck to everyone else learning! ^-^/


Thanks for that. It got me confused indeed. This helped clarify things.