Note that there are some explanatory texts on larger screens.

plurals
  1. PO'for loop' and possible syntax error
    text
    copied!<p>Here is my current javascript. I know that it worked until I added the 'for loop'. The point of the for loop is to switch letters. As it stands, its checking to see if groups of 3 are equal to one letter. I will fix that later, but I know there must be a syntax error, as the buttons don't fade as my mouse moves over them. I know this is a stupid question and I'll kick myself when I see the error, but I'm tired and can't find it for my life right now. Also, is this for loop a valid way of changing letters? Is that the correct way to set an array value to the new letter?</p> <p>Here is the script.js:</p> <pre><code> $(document).ready(function() { $('#button_translate').mouseenter(function() { $('#button_translate').fadeTo('fast', 1); }); $('#button_translate').mouseleave(function() { $('#button_translate').fadeTo('fast', 0.7); }); $('#button_clear').mouseenter(function() { $('#button_clear').fadeTo('fast', 1); }); $('#button_clear').mouseleave(function() { $('#button_clear').fadeTo('fast', 0.7); }); $('#button_translate').click(function() { var dna = $('input[name=dna]').val(); var dna = dna.toUpperCase(); function allBases(text) { var bases = /^[ACGT]+$/; if(text.match(bases)) { var arr = text.match(/.{1,1}/g); /*document.write(arr + " is a DNA sequence.");*/ for (var i = 0; i &lt; (dna.length); i++) { if (arr[i]==='A') { arr[i]='U' }else if (arr[i]==='C') { arr[i]='G' }else if (arr[i]==='G') { arr[i]='C' }else if (arr[i]==='T') { arr[i]='U' }else{ document.write(dna + " is not a real DNA sequence. Error Code 2"); } } document.write(dna + " is the translated mRNA strand!"); }else{ document.write(dna + " is not a real DNA sequence."); } } allBases(dna); }); }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload