Skip to content
Permalink
708762f8c6
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
31 lines (27 sloc) 526 Bytes
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Recursion</title>
</head>
<body>
<script>
var isEven = function(num) {
num = Math.abs(num);
if (num === 0)
return true;
else if (num === 1)
return false;
else
return isEven(num - 2);
};
console.log(isEven(50));
// → true
console.log(isEven(75));
// → false
console.log(isEven(-1));
// → ??
</script>
</body>
</html>