I am struggling to create an array of objects using JavaScript and facing errors with new lines added where I need to split the messages and collect row numbers. The row numbers should be comma-separated if it is a repetitive error message.
I found a solution but it seems messy as it adds an "undefined" string when concatenating the rows numbers.
Furthermore, I require a solution optimized for handling large data as I can expect error messages ranging from 3000 to 7000. Also, I am working with Angular 6 version.
Here is my desired output:
{
"No address details found for record at row ": "3,4",
"Invalid Street Number at row ": "5",
"Invalid Zip at row": "6,7,11"
}