I see both return true or false upon given tests.
What should be the right case to use them both together ?
Test code:
function checkUsersValid(goodUsers) {
return function allUsersValid(submittedUsers) {
//Im testing arrays here
return submittedUsers.every(function isBigEnough(element, index, array) {
return goodUsers.some(function (el, i, arr) {
return element.id == el.id;
});
});
};
}
var goodUsers = [
{ id: 1 },
{ id: 2 },
{ id: 3 }
];
var testAllValid = checkUsersValid(goodUsers);
testAllValid([
{ id: 2 },
{ id: 1 }
]);
Aucun commentaire:
Enregistrer un commentaire