JavaScript program to check the number of occurrences of a character in a string:
function countChar(str, char) {
let count = 0;
for (let i = 0; i < str.length; i++) {
if (str[i] == char) {
count++;
}
}
return count;
}
console.log(countChar("javascript", "a"));