Created
December 15, 2016 09:43
-
-
Save merss19/33182e4e4bea8ca897472e06e2479d01 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 isEven(number) { | |
return number % 2; | |
} | |
В случае четности функция возвращает 0(false), исходя из описания должно быть true. | |
Лучше, чтобы функция возвращал тип bool, чтобы не сравнивать number и bool | |
function isEven(number) { | |
if(number % 2 === 0) { | |
return true | |
} else { | |
return false | |
} | |
} | |
test('Yes, even', function() { | |
expect(isEven(2)).toBe(true); | |
}); | |
test('No, odd', function() { | |
expect(isEven(3)).toBe(false); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment