获取最大最小数值以及下标
/** * 获取数组最大值下标 */ const findMaxIndex = (numberList) => { let maxValue = parseFloat(numberList[0]); let minValue = parseFloat(numberList[0]); let maxIndex = 0; let minIndex = 0; for (let i = 0; i < numberList.length; i++) { let current = parseFloat(numberList[i]); if (current > maxValue) { maxValue = current; maxIndex = i; } else if (current < minValue) { minValue = current; minIndex = i; } } return maxIndex }