I am currently attempting to utilize the array.some
function to traverse through a dataset and retrieve my field
when the specified condition is met.
However, what I'm experiencing is that instead of obtaining the variable (which holds details to an element), I am receiving a boolean value like true
as the output.
for (var index in allFields) {
const invalidField = allFields[index].some(function (field){
if (!validation.getIn([index, field.dataset.fieldKey, 'isValid'])) {
return field;
}
});
if (invalidField) {
return invalidField;
}
}
My code essentially loops through the allFields
, which consists of lists of fields indexed accordingly. It then compares each fieldKey
with another data set named validation
.
The intention is to have the field
returned since it contains an element. However, upon verifying invalidField
, I am only getting true
rather than the desired element.