Javascript : How to add comma to string element in interface

Hi have below structure for user interface –

export interface IUser {
  EMPLOYEE_NAME :string,
  EMPLOYEE_PID : string

At a point in a code , I am receiving array of IUser – IUser[] with multiple employeenames and their pids.



I want to fetch comma seperated PIDs – ‘A123′,’B123’

I tried with map and foreach but not able to loop properly as its interface.


You can use and Array.prototype.join to achieve.

let data = [{EMPLOYEE_NAME:'XYZ',EMPLOYEE_PID :'A123'},

let result = => x.EMPLOYEE_PID).join(',');

If you want to wrap the ids in comma

let data = [
let result = => `'${x.EMPLOYEE_PID}'`).join(',');