2
I have an array which is as follows
[
{
"Param": 1,
"Valor": 68
},
{
"Param" 1,
"Valor": 79
},
{
"Param": 2,
"Valor": 165
}
]
I would like to know how to verify the number (no Valor
) exists in the array, if it exists, I remove, if it does not exist, I add.
I’m doing it by scoring one checkbox
, if I mark, I add in the array, if I clear, I remove, I am not using jQuery.
My code to add
this.checkOne.push({
"Param": check,
"Valor": id
})
I tried to do the following to withdraw
this.checkOne.map(val => {
if(val.Valor.indexOf(id) != -1){
alert('Tem')
}else{
alert('nao tem')
}
})
If it’s a
checkbox
that will control, not just check whether it is selected or not? Because if it was selected, the element must exist, if it was not, you will enter the value.– Woss