日日行,不怕千万里

javascript --- 数组输出数组中最大值最小值差值

Array.prototype.outputMaxPrice  = function outputMaxPrice (array) {

  const item1 = Math.max.apply( Math, array );

  const item2 = Math.min.apply( Math, array );

  return item1 - item2;
}

const array = new Array;

array.outputMaxPrice ([1, 3, 33, 44])   //  43

posted @ 2017-10-30 23:29  GongXiaoZhu  阅读(1234)  评论(0编辑  收藏  举报