File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -3,12 +3,14 @@ const sumAll = function(first, last) {
3
3
return 'ERROR'
4
4
} else if ( ( last < 0 ) || ( ! last . typeOf === 'number' ) ) {
5
5
return 'ERROR'
6
- } else {
6
+ } else if ( first < last ) {
7
7
var finalSum = 0
8
8
for ( var i = first ; i <= last ; i ++ ) {
9
9
finalSum += i
10
10
}
11
11
return finalSum
12
+ } else {
13
+ //something to figure out how to reverse this
12
14
}
13
15
}
14
16
Original file line number Diff line number Diff line change @@ -4,10 +4,10 @@ describe('sumAll', function() {
4
4
it ( 'sums numbers within the range' , function ( ) {
5
5
expect ( sumAll ( 1 , 4 ) ) . toEqual ( 10 ) ;
6
6
} ) ;
7
- xit ( 'works with large numbers' , function ( ) {
7
+ it ( 'works with large numbers' , function ( ) {
8
8
expect ( sumAll ( 1 , 4000 ) ) . toEqual ( 8002000 ) ;
9
9
} ) ;
10
- xit ( 'works with larger number first' , function ( ) {
10
+ it ( 'works with larger number first' , function ( ) {
11
11
expect ( sumAll ( 123 , 1 ) ) . toEqual ( 7626 ) ;
12
12
} ) ;
13
13
xit ( 'returns ERROR with negative numbers' , function ( ) {
You can’t perform that action at this time.
0 commit comments