{"ScriptPreparationCode":"function sumWithReduce(arr) {\r\n return arr.reduce((x, y) =\u003E (y = \u002By) ? x \u002B y: x, 0)\r\n}\r\n\r\nfunction sumWithReduceInt16(arr) {\r\n return arr.reduce((x, y) =\u003E x \u002B y, 0)\r\n}\r\n\r\nfunction sumWithLoop(arr) {\r\n let length = arr.length;\r\n let init = 0;\r\n let val;\r\n \r\n while (length--)\r\n if (val = \u002Barr[length])\r\n init \u002B= val;\r\n \r\n return init; \r\n}\r\n\r\nfunction sumWithLoopInt16(arr) {\r\n let length = arr.length;\r\n let init = 0;\r\n let val;\r\n \r\n while (length--)\r\n \tinit \u002B= val;\r\n \r\n return init; \r\n}\r\n\r\nconst nums = Array.from({length: 10000}, () =\u003E Math.floor(Math.random() * 65536))\r\n// throw in some non numbers\r\nnums[4] = \u00275\u0027; nums[22] = NaN;\r\n// coerces non numbers to zero\r\nconst numsInt = new Uint16Array(nums);","TestCases":[{"Name":"Sum with 16-bit array and loop","Code":"sumWithLoopInt16(numsInt)","IsDeferred":false},{"Name":"Sum with standard array and reduce","Code":"sumWithReduce(nums)","IsDeferred":false},{"Name":"Sum with standard array and loop","Code":"sumWithLoop(nums)","IsDeferred":false},{"Name":"Sum with 16-bit array and reduce","Code":"sumWithReduceInt16(numsInt)","IsDeferred":false}]}