数组查找谷峰值

var arr=[1,2,55,3,4,5,66,7,8,9,10,12,13];
var a=[]
for(var i=0;i<arr.length;i++){
if(arr[i]>arr[i+1]&&arr[i]>arr[i-1]){
a.push(arr[i])
}
}
console.log(a)
原文地址:https://www.cnblogs.com/liuhao-web/p/10459780.html