function countChar(b, n) {var result = 0; for (var i = 0; i < b.length; i++) { if (b.charAt(i) == n) { result ++; } }return result; } alert(countChar("hendhendhend", "e"))