我有一個簡單的數組:提取值當條件滿足
var c = [4,5,6,7,8,9,10,11,12];
我通過數組迭代,試圖返回的符合條件的值:
$.each(c, function() {
// I need to pass each value from the array as the
// last argument in the function below
var p = get_shutter_price(width, height, c);
if (p > 0) {
// Return the value from the array which allowed the condition to be met
console.log(c);
}
});
這確實不按預期工作,因爲整個數組正在傳遞到函數中。
如何返回數組中允許條件滿足的值表單?
例如,如果從陣列的數量是一個返回大於一個價格,然後返回。
所有的值,還是隻有第一個符合條件? – Yoshi