I ave two arrays with objects in them
var requiredfileds=[
{name:'CVR', value:'cvr_code'},
{name:'NODE POINT VAL', value:'node_point_val'},
]
The second array
var results = [
{name:'CVB', data:[12,11,233,445]}
{name:'CVR', data:[125,1,-45,4]}
]
Now i want to check to ensure that all the names in the required fields array are in the results array. So from the above two examples i expect it to be false and get the required field missing to be {name:'NODE POINT VAL', value:'node_point_val'},
So i have tried (with es6)
this.is_valid = true;
this.requiredfields.forEach(field=>{
this.results.forEach(item=>{
this.is_valid = item.name === field.name;
})
})
But the above doesnt work, How do i proceed
.every()..everyreturns true if all values pass a test, I don't think that would give the op what they're looking for.