Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. export const toRna = function(dna) {
  2. var rnaString = []; //following phrases push to an array
  3. for (var i=0; i < dna.length; i++) {
  4. switch(dna[i]) {//check character instead all string
  5. case 'G':
  6. rnaString.push('C');
  7. continue;
  8. case 'C':
  9. rnaString.push('G');
  10. continue;
  11. case 'A':
  12. rnaString.push('U');
  13. continue;
  14. case 'T':
  15. rnaString.push('A');
  16. continue;
  17. default: //this function will always appear if the others aren't met
  18. throw 'Invalid input DNA.'
  19. }
  20. }
  21. return rnaString.join('');
  22. } //pushed the array into a string
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement