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 = [1, 2, 3, 4, 5]
- const ys = [6, 7, 'a', 9, 10]
- const areXsIntegers = xs.every(checkAndLog)
- // passed by 1
- // passed by 2
- // passed by 3
- // passed by 4
- // passed by 5
- console.log(areXsIntegers) // true
- const areYsIntegers = ys.every(checkAndLog)
- // passed by 6
- // passed by 7
- // passed by a
- console.log(areYsIntegers) // false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement