javascript - Getting Maximum Call Stack Size Exceeded Error in Satisfiable Recursive Function -


the code supposed output random string array [non-repeating] each time function called, outputs undefined, , there seems no pattern. after number of calls "maximum call stack size exceeded" think unsatisfiable recursive function i'm not sure.

var reasons = ["you're best cook", "you're best mommas", "you call me greatest names", "you're stable", "you super funny of time, though it's not on purpose sometimes", "you keep daddy's weight in check", "you are.", "you print money.", "you're super patient", "you're super calm alawys", "you quiet on phone", "you're super date on new music", "you laugh @ things aren't funny."]; var checkifrandom = new array();  function getrandom() {     var randomnum = math.floor(math.random() * 12);     if (checkifrandom.indexof(randomnum) !== -1) {         getrandom();         return;     } else if (checkifrandom.indexof(randomnum) == -1) {         checkifrandom.push(randomnum);         return (randomnum);     } };  function writeword() {     document.getelementbyid("reasons").innerhtml = reasons[getrandom()] + "<br >"; }; 

code in action: http://jsfiddle.net/luyfdcto/


Comments