Skip to content

Instantly share code, notes, and snippets.

@Scoutski
Created August 10, 2015 23:59
Show Gist options
  • Save Scoutski/b03f58196a782464c8b4 to your computer and use it in GitHub Desktop.
Save Scoutski/b03f58196a782464c8b4 to your computer and use it in GitHub Desktop.
Solution for Week 2, Day 2 warmup exercise
var Nucleotide = {
countIndividualNucleotide: function( string, char ) {
var nucleotideCount = 0;
for ( var i = 0; i < string.length; i++ ) {
if (string[i] === char ) {
nucleotideCount++;
}
}
return nucleotideCount;
},
returnNucleotideCount: function( string ) {
var nucleotideTotals = {
'A': this.countIndividualNucleotide( string, 'A' ),
'C': this.countIndividualNucleotide( string, 'C' ),
'G': this.countIndividualNucleotide( string, 'G' ),
'T': this.countIndividualNucleotide( string, 'T' ),
'U': this.countIndividualNucleotide( string, 'U' )
}
return nucleotideTotals;
}
}
console.log(Nucleotide.countIndividualNucleotide("ADHFSA", "A"));
console.log(Nucleotide.returnNucleotideCount("ACGTADSGASDTUTUEGCTT"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment