Created
August 10, 2015 23:59
-
-
Save Scoutski/b03f58196a782464c8b4 to your computer and use it in GitHub Desktop.
Solution for Week 2, Day 2 warmup exercise
This file contains 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
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