Initial exercises - Project Matrix 3rd Edition:
1 - Write a function called sumIntegers to calculate the sum of integers. The function needs to test whether the entries are valid and returns undefined when the entry is invalid.
2- Write a function called sumOdd to calculate the sum of odd integers. The function needs to test whether the entries are valid and returns undefined when the entry is invalid. The input value represents the number of odd numbers, that is: f (1) = 1 f (2) = 1 + 3 = 4 f (3) = 1 + 3 + 5 = 9 … f (n) = n²
It isn't to apply the formula, but to make the code. Identify which parts of the code can be encapsulated to reduce duplication of code. Create separate functions for these pieces of code.
3- Write a file called sumEncapsulation.js and identify which parts of the code can be encapsulated, in order to reduce code duplication. Create separate functions for these pieces of code.
4 - Write a function multiplyIntegers to multiply integers, if possible already using the functions you extracted in question 3, to avoid duplication.
5- [Optional Challenge] Implement the three functions previously created recursively. Put them in a file called integer-recursive.js