Javascript How To Prevent Stack Overflow In This Recursive Path

Javascript How To Prevent Stack Overflow In This Recursive Path