countBs
function countBs(word){
var numberOfB = 0;
for (count = 0; count < word.length; count ++){
if (word[count] == "B"){
numberOfB +=1;
}
}
return numberOfB;
}
var answer = countBs(“My name is Jebel without a capital B”);
document.write(answer);
countChar
function countChar(word,char){
var numberOfChar = 0;
for (count = 0; count < word.length; count ++){
if (word[count] == char){
numberOfChar +=1;
}
}
return numberOfChar;
}
var answer = countChar(“My name is Jebel without a capital”,“M”);
document.write(answer);