For this assignment, we will be learning about Test Drivin Development (TDD). When writing Javascript in larger applications, sometimes introducing new features and code can create unintended side effects. Writing tests for your code can help you write code that doesn't have bugs and free from unintentional side effects.
For each of the following items:
- Write test(s) for the functions. Commit
- Write functions to pass the test(s) Commit.
- Fizzbuzz
- This is a classic coding exercise. Write a function that prints the numbers 0-100. But for multiples of 3 print "fizz" and multiples of 5 print "buzz" and multiples of 3 and 5 print "fizzbuzz"
- Calculator
- Write 4 functions for the basic calculator operations. (+. -, *, /)
- Write 2 more functions for 2 other calculator operations. (X!, X2, ex, ect.)
- String functions
- A function that reverses a string. (eg. "Hello" becomes "olleH")
- A function that uppercases a string.
- A function that removes all vowels.
- Object validator
- Write a function that accepts 2 parameters. One is an object, the second is a string. The function should validate that the string is a key of the object.
- Numbers
- A function that takes an array of numbers, and adds up all the numbers in the array and outputs the total. ( [1,2,3] would output: 6)
- When writing tests, try to think of edge cases for your functions and test for those cases as well as expected behavior.
- Writing tests is an art, you need to write enough to cover the use of the function, but not too much that you spend too much time writing tests.
- Tests can be written using a framework (Jest recommended) or with vanilla JS.
- Functions and Tests can be written in the same file, or for sanity, you can opt to split them into modules.