Why doesn't this run in google console?

I copied and pasted their solution into my google console and it would not run. It gave me an error. I don’t understand why.

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

const numOfMonitors = monitorCount(5, 4);


VM624:1 Uncaught SyntaxError: Identifier 'numOfMonitors' has already been declared
    at <anonymous>:1:1

However, this code did work and again I don’t understand why the solution they supplied did not work and the one below did.

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