{"size": 525, "ext": "js", "max_stars_repo_path": "hackerrank/string-manipulation/alternating-characters.js", "max_stars_repo_name": "kwr760/interview-prep", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "hackerrank/string-manipulation/alternating-characters.js", "max_issues_repo_name": "kwr760/interview-prep", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "hackerrank/string-manipulation/alternating-characters.js", "max_forks_repo_name": "kwr760/interview-prep", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 20.1923076923, "max_line_length": 38, "alphanum_fraction": 0.6342857143}
const alternatingCharacters = (s) => {
  let removals = 0;
  let currentChar = '';

  const strArray = s.split('');
  strArray.map((c) => {
    if (currentChar !== c) {
      currentChar = c;
    } else {
      removals++;
    }
  });
  return removals;
}

let s = 'AAAA';
console.log(alternatingCharacters(s));
s = 'BBBBB';
console.log(alternatingCharacters(s));
s = 'ABABABAB';
console.log(alternatingCharacters(s));
s = 'BABABA';
console.log(alternatingCharacters(s));
s = 'AAABBB';
console.log(alternatingCharacters(s));
