I was trying to call another function inside function iseven(n):
function iseven(n) {
function remainder(n) {
if (n%2==0) {
return true;
} else {
return false;
}
}
}
console.log(iseven(4));
It returns undefined.
a right way to do this:
function a(x) { // <-- function
function b(y) { // <-- inner function
return x + y; // <-- use variables from outer scope
}
return b; // <-- you can even return a function.
}
console.log(a(3)(4));