How do check if ticketId already inserted into array?
This is the code:
state = { myState: [], status: 0, limit: 5 };
selected(ticketId) {
if (this.state.status < this.state.limit) {
this.state.myState.push({ id: ticketId }); //what ever i chose get inserted
this.state.status++;
this.setState({ status: this.state.status });
//console.log('here', this.state.status);
} else {
console.log('3'); //check if condition meet
}
}
How do I create a condition checking myState array if the ticketId already insert and trigger an alert?