I am using following line of code to split an array of objects to comma separated values
var myArray = [{Name: "apple"}, {Name: "Banana "}];
type : { DisplayText: myArray.length > 0 ? myArray.map(function (elm) { return elm.Name }).join(", ") : null,
property1: 'a',
Property2: 'b'
}
Output:
apple, Banana
However, how i can generate the following output
apple
Banana
Note:
The following does not work. It generates output apple Banana
DisplayText: myArray.length > 0 ? myArray.map(function (elm) { return elm.Name }).join("\n") : null,
Update:
Actually i am creating type object with DisplayText property and two other properties. That's why i have , at the end of line . Have a look at my updated answer