Skip to content

Instantly share code, notes, and snippets.

@marsrvr
Created March 21, 2019 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marsrvr/cc333f4f12ae5edaa3b3e31f212c0153 to your computer and use it in GitHub Desktop.
Save marsrvr/cc333f4f12ae5edaa3b3e31f212c0153 to your computer and use it in GitHub Desktop.
IvanOnTech Academy Smart Contract Programming Eloquent JavaScript Chapter 3 Exercise 3: count b's
function countChar (string, char) {
 var count = string.length;
 for (var i = count - 1; i >= 0 ; i--){
  if (string[i] != char) count--;
}
 return count;
}
function countBs(string) {
return countChar(string, "B");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment