This is my first question on Stack, so please excuse me if I'm not asking this correctly.
I'm trying to solve a basic exercise that asks me to create a function named countCharacters that accepts two parameters, a character and a string. It should return the number of times the character is present in the string. This is what I have so far:
function countCharacters(char, string) {
return string.indexOf(char);
}
Please let me know where I went wrong. I'm still learning basic JavaScript and I appreciate any and all feedback!