{"ScriptPreparationCode":null,"TestCases":[{"Name":"Optimized","Code":"const randomArray = Array.from({length: 1000}, () =\u003E Math.random());\r\nconst squareArr = (arr, len) =\u003E {\r\n const array = []\r\n for (let i = 0; i \u003C len; i\u002B\u002B) {\r\n array.push(arr[i] * arr[i])\r\n }\r\n return array\r\n}\r\nconst sumArr = (arr, len) =\u003E {\r\n let total = 0\r\n for (let i = 0; i \u003C len; i\u002B\u002B) {\r\n total \u002B= arr[i]\r\n }\r\n return total\r\n}\r\nconst getMean = (arr, len) =\u003E sumArr(arr, len) / len\r\nconst calculateRMS = (arr, len) =\u003E Math.sqrt(getMean(squareArr(arr, len), len))\r\ncalculateRMS(randomArray)","IsDeferred":false},{"Name":"Original","Code":"const randomArray = Array.from({length: 1000}, () =\u003E Math.random());\r\nconst sumRdcr = (a, c) =\u003E a \u002B c\r\nconst getSum = (a) =\u003E a.reduce(sumRdcr, 0)\r\nconst calculateRMS = function (arr) {\r\n const squares = arr.map((val) =\u003E val * val)\r\n const mean = getSum(squares) / arr.length\r\n return Math.sqrt(mean)\r\n}\r\ncalculateRMS(randomArray)","IsDeferred":false}]}