I have an array that is as follows
[
{
"Param": 1,
"Valor": 68
},
{
"Param" 1,
"Valor": 79
},
{
"Param": 2,
"Valor": 165
}
]
I would like to know how to check if the number (in Valor
) exists in the array, if it exists, I remove, if it does not exist, I add.
I'm doing this by dialing checkbox
, if I mark, I add in the array, if I uncheck, I retreat, I'm not using jQuery.
My code to add
this.checkOne.push({
"Param": check,
"Valor": id
})
I tried to remove it as follows
this.checkOne.map(val => {
if(val.Valor.indexOf(id) != -1){
alert('Tem')
}else{
alert('nao tem')
}
})