function countInstancesOf(letter, sentence) { var count = 0; for (var i = 0; i < sentence.length; i++) { if (sentence.charAt(i) === letter) { count += 1; } } return count; }