If you want to check out my work on GitHub, feel free to view the code here:
The JavaScript is triggered by keydown and will create something.
I organize the output by paragraph (new line), with JS removing newlines from arrays using Regex (/[\n\r]/gm).
However, if I add more than 2 empty lines before continuing typing, the regex doesn't detect it.
Example of textarea input:
PO PO PO PO
<--This part detected as newline-->
PO
<--This part detected as newline-->
<--This part unable to detect as newline-->
PO
Result in Console.log:
["po po po po", "po", "", "po"]
My Code for getting textarea value and creating an array:
var crinput = document.getElementById("textarea1").value
var paracountarray = crinput.split(/[\n\r]/gm);
My code for removing empty strings in the array:
for(a=0;a<paracountarray.length;a++){
if(paracountarray[a] == ""){
paracountarray.splice(a,1)
}
}
Please let me know how to remove the empty strings in the array.