I'm trying to search inside temp1
if any value has the string "processado"
using the following code
let temp1 = [{
"id":7089,
"value":"R$ 50,00",
"name":"Daiany Nascimento",
"date":"18/03/2019",
"type":"Cobrança",
"status":{
"status":"Paga",
"icon":"paid"
},
"credit_release_date":"Não Processado",
"credit_release_description":"— — — —"
}]
let b = []
temp1.forEach((a,index_a) => {
Object.values(a).every((value,index,array) => {
let expression = new RegExp("processado", "i") //expression to search
if (typeof value == "object") {
Object.values(value).every(valueOfObject => {
if (expression.test(valueOfObject)) {
b.push(temp1[index_a])
return false;
} else {
return true
}
})
}
else if (expression.test(value)){
b.push(temp1[index_a])
return false
}
else {
return true
}
})
})
But, the array b remains empty. If I try to search the string "Cobrança"
, the array b get filled, as it should. I think that if I try to search values that are stored on keys after the status key, something get wrong.