{"ScriptPreparationCode":" var nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\r\n \r\n function sum_recurse(arr, i) {\r\n i = i || 0;\r\n if (i \u003E arr.length)\r\n return 0;\r\n else\r\n return arr[i] \u002B sum_recurse(arr, i \u002B 1);\r\n }\r\n\r\n function sum_recurse_tail(arr, i, sum = 0) {\r\n i = i || 0;\r\n if (i \u003E arr.length)\r\n return 0;\r\n else\r\n return sum_recurse(arr, i \u002B 1, sum \u002B arr[i]);\r\n }\r\n \r\n function sum_while(arr) {\r\n var total = 0,\r\n i = 0,\r\n len = arr.length;\r\n \r\n while (i \u003C len) {\r\n total \u002B= arr[i\u002B\u002B];\r\n }\r\n \r\n return total;\r\n }\r\n \r\n function sum_for(arr) {\r\n var total = 0,\r\n len = arr.length;\r\n \r\n for (var i = 0; i \u003C len; i\u002B\u002B) {\r\n total \u002B= arr[i];\r\n }\r\n \r\n return total;\r\n }","TestCases":[{"Name":"recursion","Code":"sum_recurse(nums)","IsDeferred":false},{"Name":"while loop","Code":"sum_while(nums)","IsDeferred":false},{"Name":"for loop","Code":"sum_for(nums)","IsDeferred":false},{"Name":"recurse (tail)","Code":"sum_recurse_tail(nums)","IsDeferred":false}]}