Created
March 21, 2019 00:03
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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