Remove string after character in every line break

Hi I'm a newbie at javascript and I have some text that contains multiple lines.I want to remove strings after the character '(' in every line breaks and then replace all line breaks with commas. This is what I have so far