Hi there I've an array of object which from which I'm returning new string by concatenating
let arr= [
{
"adsFactId": "753648",
"adsRole": "Authorized Redistributor (AR)",
"adsLicense": "Target",
"adsLicenseEffectiveDate": "04/17/2023",
"adsLicenseExpiryDate": "",
"adsDataConcept": "AlexProposed3 [P], Asset · L1, AlexProposed4 [P], AlexProposed2 [P], AlexProposed1 [P]",
"adsManagedGeography": "North America · L2",
"adsManagedSegment": "Institutional Clients Group [L3], Legacy Franchises [L3]",
"adsStatus": "Active",
"adsTechAsset": "Citi Building Controls Systems | 170794",
"selectedIds": [
"753648"
],
"checked": true,
"checkBoxPatched": true
},
{
"adsFactId": "753337",
"adsRole": "Authorized Redistributor (AR)",
"adsLicense": "Interim",
"adsLicenseEffectiveDate": "04/12/2023",
"adsLicenseExpiryDate": "04/29/2023",
"adsDataConcept": "Adsddsdsdsdd [P], AlexProposed1 [P]",
"adsManagedGeography": "Unspecified",
"adsManagedSegment": "Unspecified",
"adsStatus": "Active",
"adsTechAsset": "Citi Building Controls Systems | 170794",
"selectedIds": [
"753648"
],
"checked": true,
"checkBoxPatched": true
},
]
let newArr = arr.map(selectedObj => {
if(selectedObj.checked) {
return selectedObj.adsRole + ", " + selectedObj.adsLicense + ", " + selectedObj.adsDataConcept + ", " + selectedObj.adsManagedGeography + ", " + selectedObj.adsManagedSegment
}
}).filter((str) => str.length !== 0).join(';\n');
console.log(newArr)
Authorized Redistributor (AR), Target, AlexProposed3 [P], Asset · L1, AlexProposed4 [P], AlexProposed2 [P], AlexProposed1 [P], North America · L2, Institutional Clients Group [L3], Legacy Franchises [L3];
Authorized Redistributor (AR), Interim, Adsddsdsdsdd [P], AlexProposed1 [P], Unspecified, Unspecified
I need to add line breaks between concatenated string like above output, how can i achieve this. I tried by adding \n
at the end on string but it didn't work
');``` – Newbee Apr 19 '23 at 09:54