When i logged the totalCost to the console it gave me NaN

I am a bit confused with this Helper Function chapter. Can somebody look at my code from the exercise and explain it to me. It worked and the exercise checked out but when i logged the totalCost to the console it gave me NaN = not a number

function monitorCount(rows, columns) {

return rows * columns;

}

function monitorCount(){

}

function costOfMonitors(rows, columns){

return monitorCount(rows,columns) * 200;

}

const totalCost = costOfMonitors(5, 4);

console.log(totalCost);

I dont quite get it.

That function is overwriting the one before it since they have the same name. There being nothing in the function, a call to it will result in undefined. When we try to do math with it we get NaN.

thank you for explaining , so i have to delete that part of the code.
why did the exercise let me through then i wonder?
other times if i just miss a . or any other symbol or a type-o in a string it will not let me pass until i correct it.
or did it let me pass because it was a valid code it just gave me undefined answer?

The lesson checker may only be looking for certain signals and ignoring the output. We can often pass a lesson even when there are syntax errors. Don’t take it to mean anything, though. Watch the console for error messages and be sure you know what they mean and how to rectify the error.

1 Like