const arr = [2,35,67,3];
{"ScriptPreparationCode":"const arr = [2,35,67,3];","TestCases":[{"Name":"Array.sort","Code":"const arr = [2,35,67,3];\r\nconst a = arr.sort();\r\nconst min = a[0];\r\nconst max = a[a.length - 1];","IsDeferred":false},{"Name":"Math min and max","Code":"const arr = [2,35,67,3];\r\nconst min = Math.min(...arr);\r\nconst max = Math.max(...arr);","IsDeferred":false},{"Name":"d3 array","Code":"const arr = [2,35,67,3];\r\n\r\nfunction minF(values, valueof) {\r\n let min;\r\n if (valueof === undefined) {\r\n for (const value of values) {\r\n if (value != null\r\n \u0026\u0026 (min \u003E value || (min === undefined \u0026\u0026 value \u003E= value))) {\r\n min = value;\r\n }\r\n }\r\n } else {\r\n let index = -1;\r\n for (let value of values) {\r\n if ((value = valueof(value, \u002B\u002Bindex, values)) != null\r\n \u0026\u0026 (min \u003E value || (min === undefined \u0026\u0026 value \u003E= value))) {\r\n min = value;\r\n }\r\n }\r\n }\r\n return min;\r\n}\r\n\r\nfunction maxF(values, valueof) {\r\n let max;\r\n if (valueof === undefined) {\r\n for (const value of values) {\r\n if (value != null\r\n \u0026\u0026 (max \u003C value || (max === undefined \u0026\u0026 value \u003E= value))) {\r\n max = value;\r\n }\r\n }\r\n } else {\r\n let index = -1;\r\n for (let value of values) {\r\n if ((value = valueof(value, \u002B\u002Bindex, values)) != null\r\n \u0026\u0026 (max \u003C value || (max === undefined \u0026\u0026 value \u003E= value))) {\r\n max = value;\r\n }\r\n }\r\n }\r\n return max;\r\n}\r\n\r\nconst min = minF(arr);\r\nconst max = maxF(arr);\r\n\r\n","IsDeferred":false}]}