passes 3/6 tests
This commit is contained in:
		
							parent
							
								
									e9b1b13cfa
								
							
						
					
					
						commit
						026eb4cd91
					
				| 
						 | 
				
			
			@ -1,19 +1,24 @@
 | 
			
		|||
const sumAll = function(x, y) {
 | 
			
		||||
    let theSum;
 | 
			
		||||
    for (let i = x+1; i <=y; i++) {
 | 
			
		||||
    theSum = x += i 
 | 
			
		||||
    }
 | 
			
		||||
  
 | 
			
		||||
  return theSum
 | 
			
		||||
        if (x < 0 || y < 0) {return('ERROR')}
 | 
			
		||||
         
 | 
			
		||||
        else  
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
  if (x | y <0 ) {return('ERROR')}
 | 
			
		||||
        for (let i = x+1; i <=y; i++) {
 | 
			
		||||
        theSum = x += i 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
      
 | 
			
		||||
      }
 | 
			
		||||
        return theSum
 | 
			
		||||
    }
 | 
			
		||||
  
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Need to add conditions for ERROR-message
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Do not edit below this line
 | 
			
		||||
module.exports = sumAll;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,16 +7,16 @@ describe('sumAll', () => {
 | 
			
		|||
  test('works with large numbers', () => {
 | 
			
		||||
    expect(sumAll(1, 4000)).toEqual(8002000);
 | 
			
		||||
  });
 | 
			
		||||
  test.skip('works with larger number first', () => {
 | 
			
		||||
  test('works with larger number first', () => {
 | 
			
		||||
    expect(sumAll(123, 1)).toEqual(7626);
 | 
			
		||||
  });
 | 
			
		||||
  test('returns ERROR with negative numbers', () => {
 | 
			
		||||
    expect(sumAll(-10, 4)).toEqual('ERROR');
 | 
			
		||||
  });
 | 
			
		||||
  test.skip('returns ERROR with non-number parameters', () => {
 | 
			
		||||
  test('returns ERROR with non-number parameters', () => {
 | 
			
		||||
    expect(sumAll(10, "90")).toEqual('ERROR');
 | 
			
		||||
  });
 | 
			
		||||
  test.skip('returns ERROR with non-number parameters', () => {
 | 
			
		||||
  test('returns ERROR with non-number parameters', () => {
 | 
			
		||||
    expect(sumAll(10, [90, 1])).toEqual('ERROR');
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue