Created
September 29, 2018 08:06
-
-
Save jepras/5ff0186450f20d795fdcad1d44c6de26 to your computer and use it in GitHub Desktop.
Created a function that takes in a parameter, that is then looped and called until end. Function is a switch statement.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch | |
// https://guide.freecodecamp.org/certifications/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/dna-pairing | |
function pairElement(str) { | |
var paired = []; | |
var search = function(char) { | |
switch (char) { | |
case 'A': | |
console.log("a found"); | |
paired.push(['A', 'T']); | |
break; | |
case 'T': | |
console.log("t found"); | |
paired.push(['T', 'A']); | |
break; | |
case 'C': | |
console.log("c found"); | |
paired.push(['C','G']); | |
break; | |
case 'G': | |
console.log("g found"); | |
paired.push(['G','C']); | |
break; | |
} | |
} | |
for (var i = 0; i < str.length; i++) { | |
search(str[i]); | |
} | |
return paired; | |
} | |
pairElement("GCG"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment