-1

I have a array like

let array = ["MR','JR','IR','MY"]

I want to convert it into a comma separated String like

string = MR,JR,IR,MY

Any help is appreciated and Thanks in advance

1 Answers1

-1

You need to use the join method with comma as a separator

let string = array.join(',')

EDIT: Actually your array have only one position, so you are not joining anything. You only need to replace the character ' and you are done.

let string = array[0].replace(new RegExp("'", "g"),"")
ivan5593
  • 29
  • 4