I have a very tricky manipulation to do. So here it is.
I have an array of Objects named 'data1'
[Object, Object, Object]
0:Object
id="00456145" //check this
name: "Rick"
upper:"0.67"
lower:"-0.34"
1:Object
id="00379321"
name:"Anjie"
upper:"0.46"
lower:"-0.56"
2:Object
id="00323113"
name:"dillan"
upper:"0.23"
lower:"-0.11"
I am only interested in id, upper and lower values from these array of objects.
Here is the second array of objects named 'data2'
[Object, Object]
0:Object
id="0045614" //present here if we remove last element of '00456145'
cast="Rick"
Contact: "Yes"
upper:"0.11" //need to be updated to '0.67'
lower:"-0.11" //need to be updated to '-0.34'
1:Object
id="0032311" //present here if we remove last element of '00323113'
cast:"dillan"
Contact:"Maybe"
upper:"0.11"
lower:"-0.11"
So, this is what i have to do. I will first check 'data1'. id present in 'data1' is checked. For e.g. object 0 has id="00456145"
I remove the last number present in it. so it becomes id="0045614". Then i compare if this id is present in the object 'data2'.
If it is present, the upper and lower values present for that object 0 in 'data1' is passed to object 'data2' where the id is present. In this case object 0 of 'data2' has the id= '0045614'.
So upper and lower values will be updated to 0.67 and -0.34 respectively.
Similarly for other arrays. So the final output should look like this of 'data2'
[Object, Object]
0:Object
id="0045614"
cast="Rick"
Contact: "Yes"
upper:"0.67" //updated
lower:"-0.34" //updated
1:Object
id="0032311"
cast:"dillan"
Contact:"Maybe"
upper:"0.23" //updated
lower:"-0.11" //updated