Skip to content

Instantly share code, notes, and snippets.

@aarti
Created July 8, 2014 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aarti/700190aa319dbc6db4c5 to your computer and use it in GitHub Desktop.
Save aarti/700190aa319dbc6db4c5 to your computer and use it in GitHub Desktop.
Javascript Map Calling directly or Generically
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