I am trying to create a function with two parameters that will count how times a character repeats in a given string. I have my code below but it is not working properly. Also, I am trying to make it a non-recursive function. Can anyone help me with that?
function count(char,word) {
var a,b;
a= char
b= word
c= b.indexof(a)
return c
}
count('a','apple')