My script (is meant to) grab text from the a page (which works fine) and then splits it by by newline (\n) and puts each splitted string into an array called "dnaSequence"; from there it loops through each element in the array and if the string contains the character ">" it assigns that string to the "var header_name", else it pushes all other lines into a new array called "dnaSubseq". The original text looks something like this:
>header_1 gctagctagc cgcgagcgagc >header_2 gcgcatgcgac When I execute the code it fails to alert on anything. Here is the code:
function loaderMy() { var dnaSubseq = []; var dnaSequence = []; var header_name = ""; var splittedLines = document.getElementById("page-wrapper").innerText; dnaSequence = splittedLines.split('\n'); for (var i = 0; i < dnaSequence.length; i++) { if (dnaSequence[i].match(/>/)) { header_name = dnaSequence[i]; alert(header_name); } else { dnaSubseq.pushValues(dnaSequence[i]); } alert(dnaSubseq); } }
pushnotpushValues