Let's practice! This testing thing really is not that difficult, but it is quite new. The only way to get comfortable with it is to spend some time doing it.
-
capitalize(string)
takes a string and returns that string with the first character capitalized. -
reverseString(string)
takes a string and returns it reversed. -
A
calculator
object that contains the basic operations:add
,subtract
,divide
, andmultiply
. -
Caesar Cipher. Read about it on this website
- Don’t forget to test wrapping from
z
toa
. - Don’t forget to test keeping the same case.
- Don't forget to test punctuation!
- For this one, you may want to split the final function into a few smaller functions. One concept of Testing is that you don't need to explicitly test every function you write... Just the public ones. So in this case you only need tests for the final
caesar()
function. If it works as expected you can rest assured that your smaller helper functions are doing what they're supposed to.
- Don’t forget to test wrapping from
-
Array Analysis. Write a function that takes an array of numbers and returns an object with the following properties:
average
,min
,max
, andlength
.const object = analyze([1,8,3,4,2,6]); object == { average: 4, min: 1, max: 8, length: 6 };
The current version of Jest as it is does not recognize the import statement. In order for you to be able to use ES6 modules for this project you may do the following:
- Install the @babel/preset-env package
npm i -D @babel/preset-env
- Create a .babelrc file in the project's root with the following lines of code:
{
"presets": ["@babel/preset-env"]
}
This will allow you to use import statements. Note that in the Jest docs a similar instruction is laid out here
To add your solution to the list below, edit this file (located on The Odin Project's "curriculum" github repository). See the section on Contributing for more instructions.
Show Student Solutions
- Add your solution below this line!
- James's solution
- Kevin Vuong's solution
- Julio's solution
- Martink-rsa's solution
- Igorashs's solution
- Vedat's solution
- Ben's solution
- Solodov's solution
- ARaut9's solution
- Jason McKee's solution
- Max Garbers's solution
- theghall's solution
- Jmooree30's solution
- Devon's solution
- Rhys' solution
- heyalvaro's solution
- Mike Smith's solution
- MPalhidai's solution
- Areeba's solution
- scotth527's solution
- Ryan Floyd's solution
- Aron's solution
- Ivnosing's solution
- barrysweeney's solution