Q:

Write a JavaScript program to check if the predicate (second argument) is truthy on all elements of a collection (first argument)

0

Write a JavaScript program to check if the predicate (second argument) is truthy on all elements of a collection (first argument).

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

const truthCheckCollection = (collection, pre) => collection.every(obj => obj[pre]);
console.log(truthCheckCollection([{ user: 'Tinky-Winky', sex: 'male' }, { user: 'Dipsy', sex: 'male' }], 'sex'));

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now