File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -9,12 +9,12 @@ const sumAll = function(first, last) {
9
9
finalSum += i
10
10
}
11
11
return finalSum
12
- } else if ( first > last ) {
12
+ } else if ( first > last ) {
13
13
//something to figure out how to reverse this
14
- var finalSum = 0 ;
14
+ var fakeFirst = first ;
15
15
first = last ;
16
- last = first ;
17
- for ( var i = last ; i <= first ; i ++ ) {
16
+ last = fakeFirst ;
17
+ for ( var i = first ; i <= last ; i ++ ) {
18
18
finalSum += i
19
19
}
20
20
return finalSum
Original file line number Diff line number Diff line change @@ -10,13 +10,13 @@ describe('sumAll', function() {
10
10
it ( 'works with larger number first' , function ( ) {
11
11
expect ( sumAll ( 123 , 1 ) ) . toEqual ( 7626 ) ;
12
12
} ) ;
13
- xit ( 'returns ERROR with negative numbers' , function ( ) {
13
+ it ( 'returns ERROR with negative numbers' , function ( ) {
14
14
expect ( sumAll ( - 10 , 4 ) ) . toEqual ( 'ERROR' ) ;
15
15
} ) ;
16
- xit ( 'returns ERROR with non-number parameters' , function ( ) {
16
+ it ( 'returns ERROR with non-number parameters' , function ( ) {
17
17
expect ( sumAll ( 10 , "90" ) ) . toEqual ( 'ERROR' ) ;
18
18
} ) ;
19
- xit ( 'returns ERROR with non-number parameters' , function ( ) {
19
+ it ( 'returns ERROR with non-number parameters' , function ( ) {
20
20
expect ( sumAll ( 10 , [ 90 , 1 ] ) ) . toEqual ( 'ERROR' ) ;
21
21
} ) ;
22
22
} ) ;
You can’t perform that action at this time.
0 commit comments