Finding range of an array

Finding range of an array
0.0 0


I’m looking to write a function function range (arr) which takes an array, finds the highest and lowest value of that array, subtracts those values and return the total. So for example, the array [6,2,3,4,9,6,1,0,5]) would return 8, as 9 is the highest, 1 is the lowest, and then would subtract the two.

Any help would be greatly appreciated.



You may want to look into the Math.max and Math.min functions, along with the spread operator to get them to work for arrays.


got it!! thanks man really appreciate it