-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDNAPairing.js
More file actions
36 lines (25 loc) · 965 Bytes
/
DNAPairing.js
File metadata and controls
36 lines (25 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function pairElement(nucleotideString) {
var dnaBasePairs = [["A", "T"], ["C", "G"], ["G", "C"], ["T", "A"]];
var basePairToAdd;
var matchesBasePairs = [];
//loop through each character of the nucleotideString
for (var i = 0; i < nucleotideString.length; i++) {
//match up character with appropriate base pair
findBasePair(nucleotideString[i]);
function findBasePair(nucleotide) {
basePairToAdd = dnaBasePairs.filter(
function (nucleotideInBasePairArray) {
if (nucleotide === nucleotideInBasePairArray[0]) {
return true;
}
}
);
// console.log(basePairToAdd);
basePairToAdd = basePairToAdd[0];
// console.log(basePairToAdd);
matchesBasePairs.push(basePairToAdd);
}
}
return matchesBasePairs;
}
console.log(pairElement("GCG"));