0% found this document useful (0 votes)
21 views1 page

Dna Pairing

The document contains a JavaScript function named 'pairElement' that takes a string representing DNA sequences and returns an array of arrays containing the corresponding base pairs for each character. It uses a helper function 'matchWithBasePair' to determine the pairs for 'A', 'T', 'C', and 'G'. The function is tested with the input 'GCG'.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views1 page

Dna Pairing

The document contains a JavaScript function named 'pairElement' that takes a string representing DNA sequences and returns an array of arrays containing the corresponding base pairs for each character. It uses a helper function 'matchWithBasePair' to determine the pairs for 'A', 'T', 'C', and 'G'. The function is tested with the input 'GCG'.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

function pairElement(str) {

// Function to match each character with the base pair


const matchWithBasePair = function(char) {
switch (char) {
case "A":
return ["A", "T"];
case "T":
return ["T", "A"];
case "C":
return ["C", "G"];
case "G":
return ["G", "C"];
}
};

// Find pair for every character in the string


const pairs = [];
for (let i = 0; i < str.length; i++) {
pairs.push(matchWithBasePair(str[i]));
}

return pairs;
}

// test here
pairElement("GCG");

You might also like