Q:

Logging a variable to the console

How do I log the variable totalCost to the console? I am getting an error when trying to run this code
Tried using console.log(totalCost);
function monitorCount(rows, columns) {
  return rows * columns;
}

function costOfMonitors(rows, columns){
  return monitorCount(rows, columns) * 200;

  const totalCost = costOfMonitors(5, 4);

}

console.log(totalCost);

A:

The return keyword ends a function after the code in its line has been executed.
Also, totalCost is in the scope of your countOfMonitors function, so you can't access it from somewhere else.
To add to that, even if you swapped your return statement and your declaration, you would create an infinite loop with recursion, as you're calling a the same function inside a function.
This should get it working:
function monitorCount(rows, columns) {
  return rows * columns;
}

function costOfMonitors(rows, columns){
  return monitorCount(rows, columns) * 200;
}
const totalCost = costOfMonitors(5, 4);
console.log(totalCost);

