We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e67b6bf commit bc20bf1Copy full SHA for bc20bf1
my-code-challenges/minMax.js
@@ -0,0 +1,12 @@
1
+function miniMaxSum(arr) {
2
+ // Write your code here
3
+ //first sort the array
4
+ arr.sort((a,b) => a - b)
5
+ // console.log(arr)
6
+ let max = arr[0] + arr[1] + arr[2] + arr[3];
7
+ let min = arr[1] + arr[2] + arr[3] + arr[4];
8
+ //or one could use for loop to iterate over sorted array - add elements to find max and min
9
+ console.log(`${max} ${min}`)
10
+
11
12
+}
0 commit comments