npm install
npm test
Follow the TDD rules:
- You can't write any production code until you have first written a failing unit test.
- You can't write more of a unit test than is sufficient to fail, and not compiling is failing.
- You can't write more production code than is sufficient to pass the currently failing unit test.
Follow the RGR cycle.
- Red - create a unit test that fails.
- Green - Write code that makes the test pass.
- Refactor - Clean up the mess you just made.
With the actual tests described below, try to not read ahead. Focus on the above and not on the final code.
Count(null) ==> returns 0
Count(" \n\n\t\r ") ==> returns 0
Count("Hello") ==> returns 1
Count("Hello world") ==> returns 2
Count(" \nHello \r ") ==> returns 1
Count("Hello crazy \n world") ==> returns 3
Count("Hello world in world") ==> returns 3
Count("Hello world hello") ==> returns 2
Count("Hello world hello.") ==> returns 2
Count("Hello (world) - 123.") ==> returns 3
Count("Allô? Allo est la fin.") ==> returns 4