Write a program that receives a single string, receives a specific character, and finds out how many of that specific character exists in the inputted string. The length of the string does not exceed 100.
A string is given on the first line, and a character is given on the second line.
COMPUTERPROGRAMMING
R
Prints the number of characters in the first line.
3
for ... of
function solution(s, t) {
let answer = 0;
for (let x of s) {
if (x === t) answer++;
}
return answer;
}
split()
function solution(s, t) {
let answer = s.split(t).length - 1;
return answer;
}