Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/marijnh/Eloquent-JavaScript
/ isEven
Function
isEven
code/solutions/03_2_recursion.js:1–6 ·
view source on GitHub ↗
(n)
Source
from the content-addressed store, hash-verified
1
function
isEven(n) {
2
if
(n == 0)
return
true;
3
else
if
(n == 1)
return
false;
4
else
if
(n < 0)
return
isEven(-n);
5
else
return
isEven(n - 2);
6
}
7
8
console.log(isEven(50));
9
// → true
Callers
1
03_2_recursion.js
File · 0.85
Calls
no outgoing calls
Tested by
no test coverage detected