JSFiddle - React, Tailwind, and code Playground

HTML

<textarea id="hi" name="Text1" cols="40" rows="5" placeholder="enter one wdg in one line"></textarea>
<input type="button" value="test" />
<div id="inthis"></div>

CSS

textarea {
    white-space:pre-wrap;
}

JavaScript

$('input[type=button]').click(function () {
    var html = "";
    var lines = $('#hi').val().split('\n');
    for (var i = 0; i < lines.length; i++) {
        //code here using lines[i] which will give you each line
        html += lines[i];
        html += ",";
    }
    html = html.substring(0,html.length-1);
    $("#inthis").html(html);
});