doc_step-many-statements.html 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <!-- Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ -->
  3. <!doctype html>
  4. <html>
  5. <head>
  6. <meta charset="utf-8"/>
  7. <title>Debugger test page</title>
  8. </head>
  9. <body>
  10. <button id="start">Start!</button>
  11. <script type="text/javascript">
  12. function normal(aArg) {
  13. debugger;
  14. var r = 10;
  15. var a = squareAndOne(r);
  16. var b = squareUntil(r, 99999999999); //recurses 3 times, returns on 4th call
  17. var c = addUntil(r, 5, 1050); // recurses 208 times and returns on the 209th call
  18. return a + b + c;
  19. }
  20. function squareAndOne(arg){
  21. return (arg * arg) + 1;
  22. }
  23. function squareUntil(arg, limit){
  24. if(arg * arg >= limit){
  25. return arg * arg;
  26. }else{
  27. return squareUntil(arg * arg, limit);
  28. }
  29. }
  30. function addUntil(arg1, arg2, limit){
  31. if(arg1 + arg2 > limit){
  32. return arg1 + arg2;
  33. }else{
  34. return addUntil(arg1 + arg2, arg2, limit);
  35. }
  36. }
  37. var normalBtn = document.getElementById("start");
  38. normalBtn.addEventListener("click", normal, false);
  39. </script>
  40. </body>
  41. </html>