Javascript Onrest Function Not Behaving Propperly Stack Overflow

Javascript Onrest Function Not Behaving Propperly Stack Overflow