title: Program Count Occurrence Given Character String
signature: function programCountOccurrenceGivenCharacterString(s: string, c: string): number {
source_py: def program_count_occurrence_given_character_string(s, c):
      res = 0
      for i in range(len(s)):
          if (s[i] == c):
              res = (res + 1)
      return res
source_cpp: int program_count_occurrence_given_character_string(string s, char c) {
    int res = 0;
    for ( int i = 0;
    i < s . length ( );
    i ++ ) if ( s [ i ] == c ) res ++;
    return res;
  }
question_info.test_list: [{"idx": 0, "outputs": 0, "inputs": {"s": "mhjnKfd", "c": "l"}}, {"idx": 1, "outputs": 3, "inputs": {"s": "716662107", "c": "6"}}, {"idx": 2, "outputs": 1, "inputs": {"s": "01", "c": "1"}}, {"idx": 3, "outputs": 1, "inputs": {"s": "wPHSxIbnHakGRO", "c": "n"}}, {"idx": 4, "outputs": 0, "inputs": {"s": "721106", "c": "8"}}, {"idx": 5, "outputs": 0, "inputs": {"s": "111", "c": "0"}}, {"idx": 6, "outputs": 0, "inputs": {"s": "TIBFU", "c": "Q"}}, {"idx": 7, "outputs": 0, "inputs": {"s": "0", "c": "3"}}, {"idx": 8, "outputs": 1, "inputs": {"s": "10", "c": "0"}}, {"idx": 9, "outputs": 0, "inputs": {"s": "lqq", "c": "d"}}]
question_info.entry_cls_name: Solution
question_info.test_code: 
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function convertToString(value: any): string{
      return JSON.stringify(value, function (key, val) {
          if (val instanceof Set) {
              return Array.from(val);
          } return val;});
  }
  
  function validateSolution(actual: number, expected: number): boolean {
      return convertToString(actual) === convertToString(expected);
  }
  
  function driver(s: string, c: string, expected:number): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(s, c),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver("mhjnKfd", 'l', 0);
    console.log(`TEST-0...${result}`);
  
    result = driver("716662107", '6', 3);
    console.log(`TEST-1...${result}`);
  
    result = driver("01", '1', 1);
    console.log(`TEST-2...${result}`);
  
    result = driver("wPHSxIbnHakGRO", 'n', 1);
    console.log(`TEST-3...${result}`);
  
    result = driver("721106", '8', 0);
    console.log(`TEST-4...${result}`);
  
    result = driver("111", '0', 0);
    console.log(`TEST-5...${result}`);
  
    result = driver("TIBFU", 'Q', 0);
    console.log(`TEST-6...${result}`);
  
    result = driver("0", '3', 0);
    console.log(`TEST-7...${result}`);
  
    result = driver("10", '0', 1);
    console.log(`TEST-8...${result}`);
  
    result = driver("lqq", 'd', 0);
    console.log(`TEST-9...${result}`);
  
  };
  
  main();
question_info.extension: ts
question_info.entry_fn_name: programCountOccurrenceGivenCharacterString
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: tsc --target es2020 --lib es5,dom,es2015,es2020 __FILENAME__
question_info.commands: node __FILENAME__.js