re: Critique my JS solution to this CodeWars Kata VIEW POST

VIEW FULL DISCUSSION
 

I see no problem with your solution. I like how you iteratively improved your solution.

Here is my solution.

var complements = { A: 'T', T:'A', C: 'G', G: 'C'}

function DNAStrand(dna){
var dnaArray = [...dna]; //turns string into arrary , where each character is an element

 var complementArray = dnaArray.map(x => complements[x]) //maps each character with it's complement and puts the result in an array

 return complementArray.join("") //turn array into a string

}

or in one line

var complements = { A: 'T', T:'A', C: 'G', G: 'C'}

function DNAStrand(dna){
 return  [...dna].map(x => complements[x]).join("")
}
 
code of conduct - report abuse