-
-
Save Shelob9/2983e50689b65dcf473fd2e4c9cc442a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function addTwoNumbers(numberOne, numberTwo){} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe( 'Adding two number', () => { | |
| it( 'works with postive numbers', () => { | |
| expect( addTwoNumbers(1,2) ).toBe(3); | |
| }); | |
| it( 'works with a negative number', () =>{ | |
| expect( addTwoNumbers(-1,2) ).toBe(1); | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function addTwoNumbers(numberOne, numberTwo){ | |
| return numberOne + numberTwo; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe( 'Adding two number', () => { | |
| it( 'works with postive numbers', () => { | |
| expect( addTwoNumbers(1,2) ).toBe(3); | |
| }); | |
| it( 'works with a negative number', () =>{ | |
| expect( addTwoNumbers(-1,2) ).toBe(1); | |
| }); | |
| it( 'rounds when rounding argument is passed', () => { | |
| expect( addTwoNumbers( 1, 2.555555, 2 ) ).toBe( 3.55 ); | |
| }); | |
| it( 'Does not round by default', () => { | |
| expect( addTwoNumbers( 1, 2.555555 ) ).toBe( 3.555555 ); | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function addTwoNumbers(numberOne, numberTwo, precision = null ){ | |
| let sum = numberOne + numberTwo; | |
| if( precision ){ | |
| sum = Number.parseFloat(sum).precision(4); | |
| } | |
| return sum; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment