Ad
  • Custom User Avatar

    Because you will overwrite prior replaces. Anything that is lowercase is the new (already replaced/processed) value, and the caps values still need replacing/processing.

    example:

    function DNAStrand(dna){
      return dna.replace(/A/g, 'T').replace(/T/g, 'A').replace(/C/g, 'G').replace(/G/g, 'C');
    }
    DNAStrand("AAAA")
    

    The first replace turns "AAAA" into "TTTT" then the second replace turns it right back into "AAAA"

  • Custom User Avatar

    the same thought as you