Your calls are made recursively which pushes functions on to the stack infinitely that causes max call stack ...
stackoverflow.com