0
私は配列(key、startValue、EndValue)を持っています。エレメントをプッシュエレメントの前にチェックする
var fruits = [[1,10, 15], [1,25, 30]];
私は同様に私はキー2,3,4,5、電気ショック療法を持ってプッシュ
console.log(push([1,5, 35])); // false
console.log(push([2,5, 35])); // true
console.log(push([1,30, 40])); // true
console.log(push([1,15, 25])); // true
console.log(push([1,5, 10])); // true
console.log(fruits);
前に検証したいと思います。
私は以下のスクリプトで作業しています。
function push(array) {
return fruits.every(function(a) {
return array[0] == a[0] && (array[2] <= a[1] || a[2] <= array[1]);
}) && fruits.push(array) && true;
}
私のスクリプトが唯一のstartValue、endValueのためではなく、キーの作品です。 –
なぜそれが 'console.log(push([2,5、35]))ですか? //真 ''真 '? –
ありがとう、ありがとう、それは真実になるはずです。 –