Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I need when add statusdate exist before on collectfulldata then remove exist and and add new one

and if not exist add it .

meaning i dont need two statusdata with same name exist two time .

and if statusdata not exist add it .


current result
JavaScript
full data is Text5='Lifecycle',Text6='Package',Text7='Parametric'


Expected result

if add Text8='car' to collectfulldata add it because not exist
if add Text6='OBS' add it but remove exist as Text6='Package'

What I have tried:

JavaScript
initcollectdropdowslist=[]; 
collectfulldata:string; 
let textdata=$event.target.options[$event.target.options.selectedIndex].text; 
let statusdata:any = this.FilterBinddata.filter(s=>s.reportSource==textdata)[0].reportSource2; 
this.collectfulldata= statusdata + "=" + "'" + textdata + "'"; 
this.initcollectdropdowslist.push(this.collectfulldata); 
console.log("full data is " + this.initcollectdropdowslist)
Posted
Updated 17-May-20 18:37pm

1 solution

An array has a find method you can use to see if an object exists in it
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900