implemented solutions to hello world and leap year
This commit is contained in:
		
							parent
							
								
									9c3bcb49f8
								
							
						
					
					
						commit
						9bd8c4d340
					
				| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
const helloWorld = function() {
 | 
			
		||||
  return ''
 | 
			
		||||
const helloWorld = () => {
 | 
			
		||||
  return 'Hello, World!'
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
module.exports = helloWorld;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,19 @@
 | 
			
		|||
const leapYears = function() {
 | 
			
		||||
const leapYears = (year) => {
 | 
			
		||||
 | 
			
		||||
    const modulo = year % 4;
 | 
			
		||||
        if (modulo === 0 ){
 | 
			
		||||
            if(year % 100 === 0){
 | 
			
		||||
                if (year % 400 === 0){
 | 
			
		||||
                    return true;
 | 
			
		||||
                } else {
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
            } 
 | 
			
		||||
            return true;
 | 
			
		||||
   
 | 
			
		||||
        } 
 | 
			
		||||
    return false;    
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
module.exports = leapYears;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,19 +4,20 @@ describe('leapYears', () => {
 | 
			
		|||
  test('works with non century years', () => {
 | 
			
		||||
    expect(leapYears(1996)).toBe(true);
 | 
			
		||||
  });
 | 
			
		||||
  test.skip('works with non century years', () => {
 | 
			
		||||
 | 
			
		||||
  test('works with non century years', () => {
 | 
			
		||||
    expect(leapYears(1997)).toBe(false);
 | 
			
		||||
  });
 | 
			
		||||
  test.skip('works with ridiculously futuristic non century years', () => {
 | 
			
		||||
  test('works with ridiculously futuristic non century years', () => {
 | 
			
		||||
    expect(leapYears(34992)).toBe(true);
 | 
			
		||||
  });
 | 
			
		||||
  test.skip('works with century years', () => {
 | 
			
		||||
  test('works with century years', () => {
 | 
			
		||||
    expect(leapYears(1900)).toBe(false);
 | 
			
		||||
  });
 | 
			
		||||
  test.skip('works with century years', () => {
 | 
			
		||||
  test('works with century years', () => {
 | 
			
		||||
    expect(leapYears(1600)).toBe(true);
 | 
			
		||||
  });
 | 
			
		||||
  test.skip('works with century years', () => {
 | 
			
		||||
  test('works with century years', () => {
 | 
			
		||||
    expect(leapYears(700)).toBe(false);
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue