日日行,不怕千万里

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 @   GongXiaoZhu  阅读(1236)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示