Skip to content

Instantly share code, notes, and snippets.

@Noviny
Last active November 20, 2015 00:25
Show Gist options
  • Save Noviny/ccc28a728e3877fa88b0 to your computer and use it in GitHub Desktop.
Save Noviny/ccc28a728e3877fa88b0 to your computer and use it in GitHub Desktop.

Not sure how to get the filter to take two properties, so we can change the 'isNucleotide' function.

var nucleotides = {
	DNA: ["A", "C", "G", "T"],
	RNA: ["A", "C", "G", "U"],

	chosenString: "abcdaaaa",


	isNucleotide: function (value, nucleo) {
  		if (value === "A") {
  		return "A"
  		} else {
  			return null
  		}
	},

	countThis: function (string, nucleotide) {
		var comparable = string.toUpperCase().split("");
		var allNucleo = comparable.filter(nucleotides.isNucleotide);
		return allNucleo.length
	},


	countAll: function (string) {
		for (var i = 0; i < nucleotides.DNA.length; i++) {
			console.log (nucleotides.countThis(string, nucleotides.DNA[i]))
		};
	}

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment