Created
November 20, 2018 20:16
-
-
Save tuvo1106/dd89a44ba800eafa18b1b37f314570c0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isEven = x=> { | |
switch (x) { | |
// base cases | |
case 0: return true; | |
case 1: return false | |
// subtracts 2 off of x until it hits 0 or 1 | |
default: return isEven(x - 2) | |
} | |
} | |
isEven(100) // true | |
isEven(99) // false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment