Suppose I have array of object as:
const bookDetails = [
{
"bookId": "1235",
"emailId": "samplek@gmail.com",
"bookIssue": [{"Book not properly aligned": true, "some issue1": true}]
},
{
"bookId": "1235",
"emailId": "s@gmampleail.com",
"bookIssue": [{"some issues with book": true, "some issue2": true}]
}]
I want the O/P as:
[
{"bookId": "1235", "emailId": "samplek@gmail.com", "bookIssue": "Book not properly aligned,some issue1"},
{"bookId": "1235", "emailId": "s@gmampleail.com", "bookIssue": "some issues with book,some issue2"}
]
For this I tried,
bookDetails.map((i) => i.bookIssue = Object.keys(i.bookIssue[0]).join(","))
It gives the O/p as required but it starts giving value as,
[{"bookId":"1235","emailId":"samplek@gmail.com","bookIssue":"0"},
{"bookId":"1235","emailId":"s@gmampleail.com","bookIssue":"0"}]
What could be the issue, is there any other way to achieve this?