_____ ___  ___ _                                                           
 |_   _|   \|   (_)                                                          
   | | | |) | |) |                                                           
  _|_| |___/|___(_) ___                      ___      __         _           
 | _ \___ __| |    / __|_ _ ___ ___ _ _     | _ \___ / _|__ _ __| |_ ___ _ _ 
 |   / -_) _` |_  | (_ | '_/ -_) -_) ' \ _  |   / -_)  _/ _` / _|  _/ _ \ '_|
 |_|_\___\__,_( )  \___|_| \___\___|_||_( ) |_|_\___|_| \__,_\__|\__\___/_|  
              |/                        |/                                   

Test-driven development (TDD) is an evolutionary approach to development which combines test-first development where you write a test before you write just enough production code to fulfill that test and refactoring

The steps are simple:

  • Write a test
  • Watch the test fail
  • Write only the code you need to make it pass
  • Refactor that code

Your task is to practice TDD by writing both the functions below and their tests

  • BUT write the TEST FIRST.

Need an example? Look at any warmup you've completed so far! Use TDD to work through the following problems. Write tests to deal with erroneous inputs and edge cases.

watch a demo