Skip to content
Permalink
b8bcfc252b
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
32 lines (30 sloc) 487 Bytes
// Your code here.
function isEven(x) {
if (x == 0){
return true;
}
else if (x == 1){
return false;
}
else if (x < 0) {
return isEven(-x);
}
else {
return isEven(x-2);
}
}
// Or
// function isEven(x){
// if (x % 2 == 0){
// return true;
// }
// else {
// return false;
// }
// }
console.log(isEven(50));
// → true
console.log(isEven(75));
// → false
console.log(isEven(-1));
// → ??