以下のように記述することで配列に条件に一致する値が存在するか検証できます。
const array = [1, 3, 5, 7, 9]
const test1 = num => num > 8
const test2 = num => num > 10
console.log(array.some(test1)) // true
console.log(array.some(test2)) // false
Go to list of users who liked
More than 1 year has passed since last update.
以下のように記述することで配列に条件に一致する値が存在するか検証できます。
const array = [1, 3, 5, 7, 9]
const test1 = num => num > 8
const test2 = num => num > 10
console.log(array.some(test1)) // true
console.log(array.some(test2)) // false
Register as a new user and use Qiita more conveniently
Go to list of users who liked