New Line To Comma

Given a multiline text, it will replace all new lines to commas

by Grant

HTML

<textarea id="hi"></textarea>
<p>
<button id="dothing">Convert New Line to Comma!</button>

JavaScript

document.getElementById("dothing").onclick=function(){
    document.getElementById("hi").value=document.getElementById("hi").value.replace(/\n/g,",");
};