this.monthList.map(sli_record => {
let rec_found = this.newlist.find(vale_record =>vale_record.Value === sli_record.Value);
if(rec_found) {
this.Results['Value'] = sli_record['Value'];
this.Results['Month'] = sli_record['Month'];
this.Results['Year'] = sli_record['Year'];
this.Results['IsSubmittedID'] = sli_record['IsSubmittedID'];
this.Results['IsEligible'] = sli_record['IsEligible'];
this.Results['BackgroundCheckdone'] = sli_record['BackgroundCheckdone'];
}
else {
this.Results['Value'] = sli_record['Value'];
this.Results['Month'] = sli_record['Month'];
this.Results['Year'] = sli_record['Year'];
this.Results['IsSubmittedID'] = 0;
this.Results['IsEligible'] = 0;
this.Results['BackgroundCheckdone'] = 0;
this.Results['UserPass'] = sli_record['UserPass'];
}
//console.log(this.Results);
return this.Results;
}
Hi I am trying to check a common value tag of one list against another and fill in the data to a new list new list "Results" according to the conditional check but not able to generate the desired result.
Whenever the column "Value" from newlist is compared with the "Value" of monthList, if there is no value exist for that particular entry(Value column of newlist) in the monthList then it should create a entry with default values in the newlist array
for eg: Consider this value
{Id: 3, Value: 'June 2022'} this does not exist on the newlist as of now but it should add an new entry like below to the newlist array
{ "Value": "June 2022", "Month": "June", "Year": 2022, "IsSubmittedID": 0, "IsEligible": 0, "BackgroundCheckdone": 0 }
newlist=[
{ Id: 0,
Month: 'May',
Year: 2022,
Value: 'February 2022',
IsSubmittedID: 0,
IsEligible: 1,
BackgroundCheckdone: 1,
},
{Id: 0,
Month: 'July',
Year: 2022,
Value: 'July 2022',
IsSubmittedID: 0,
IsEligible: 1,
BackgroundCheckdone: 1,
}]
monthList =[
{Id: 1, Value: 'August 2022'}
{Id: 2, Value: 'July 2022'}
{Id: 3, Value: 'June 2022'}
{Id: 4, Value: 'May 2022'}
{Id: 5, Value: 'April 2022'}]
**I should get my result as of below for the Results list not able to figure out how to bind the value for the according to the list**
[
{
"Value": "August 2022",
"Month": "August",
"Year": 2022,
"IsSubmittedID": 0,
"IsEligible": 0,
"BackgroundCheckdone": 0
},
{
"Value": "July 2022",
"Month": "July",
"Year": 2022,
"IsSubmittedID": 0,
"IsEligible": 1,
"BackgroundCheckdone": 1
},
{
"Value": "June 2022",
"Month": "June",
"Year": 2022,
"IsSubmittedID": 0,
"IsEligible": 0,
"BackgroundCheckdone": 0
},
{
"Value": "May 2022",
"Month": "May",
"Year": 2022,
"IsSubmittedID": 1,
"IsEligible": 1,
"BackgroundCheckdone": 1
}
]