If I write the following code, JSLint complains that 'isOdd' was used before it was defined. Is there a way to write mutually recursive code and still please JSLint?
var isEven = function(n) {
if (n === 0) {
return true;
}
return isOdd(n - 1);
};
var isOdd = function(n) {
if (n === 0) {
return false;
}
return isEven(n - 1);
};
function isOdd(n) ...etc..
– Entasisno-use-before-define
option I guess – Entasisvar isOdd;
beforevar isEven = ...
then removevar
from yourvar isOdd
– Entasis