I have a list in a string, as below (from a <textarea>
element with id=list
):
q1
q2
q3
q4
JavaScript:
var TA = document.getElementById("list").value;
lines = TA.split("\r\n");
I want lines
variable to have the values q1,q2,q3,q4
,
but the result is q1,,q2,q3,,,q4
(note the empty items)
I want to avoid the blank strings in the result array - how can I do that?