so I'm writing this very simple function and I'm trying to return it's result but all I get is NaN
error.
Here is my current code:
function m(c) {
return Math.max(c) - this.length - 1;
}
document.getElementById('app').innerHTML = m([1,4,6,8,43,2]);
<p id="app">
</p>
When I return typeof(a - this.length -1);
instead, I get a number
as a result.
function m(c) {
return typeof(Math.max(c) - this.length - 1);
}
document.getElementById('app').innerHTML = m([1,4,6,8,43,2]);
<p id="app">
</p>
So my question is why am I getting NaN
error if type of my return statement is a number?
@edit Question number 2. Is there a way for me to change the function so that it displays the result without NaN error?