jQuery jAM, Season 6

Exercise 3.2

Recursion

	 
function isEven(n){
	if(n == 0)
		return true;
	else if(n == 1)
		return false;
	else if(n < 0)
		return isEven(-n);
	else
		return isEven(n -2);
		 
}

console.log(isEven(50));
console.log(isEven(75));
console.log(isEven(-1));
	 
	 

To open the JavaScript console, press F12 or on MAC press COMMAND-OPTION-I.