Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const checkAndLog = x => {
- console.log('passed by', x)
- return Number.isInteger(x)
- }
- const xs = ['a', 1, 2, 3, 4]
- const ys = ['a', 'b', 'c', 'd', 'e']
- const xsHasinteger = xs.some(checkAndLog)
- // passed by a
- // passed by 1
- console.log(xsHasinteger) // true
- const ysHasinteger = ys.some(checkAndLog)
- // passed by a
- // passed by b
- // passed by c
- // passed by d
- // passed by e
- console.log(ysHasinteger) // false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement