Find the maximum difference of positive arrays

There are more in the open source China blog, you can go there to see! Https://my.oschina.net/u/2998098/blog/1604028

Find the maximum difference of the following positive arrays,

Example: [1,2,4,55,223];

Idea: find the maximum and minimum

The methods Math.max (), Math.min (), max and min can only handle numbers, not arrays and strings;

  ... structural assignment

let a=[1,2,4,55,223];
       let max=Math.max(...a);
       let min=Math.min(...a)
       console.log(max-min);//222

 

Guess you like

Origin www.cnblogs.com/liuXiaoDi/p/12753827.html