Created
July 8, 2014 15:20
-
-
Save aarti/700190aa319dbc6db4c5 to your computer and use it in GitHub Desktop.
Javascript Map Calling directly or Generically
This file contains hidden or 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
function genericallyCallingMap(dna) { | |
var complements = {"C":"G", "G":"C", "T":"A", "A":"U"}; | |
var map = Array.prototype.map | |
var a = map.call(dna, function(x) { | |
return complements[x]; | |
}) | |
return a.join(""); | |
}; | |
function callingMapOnAnArray(dna) { | |
var a = dna.split("").map( function(x) { | |
return complements[x]; | |
}); | |
return a.join(""); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment