Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. //MOCHA: let isOddOrEven = require("../mocha1").isOddOrEven
  2. let expect = require("chai").expect;
  3. describe("Test isOddOrEven(string)", function() {
  4. it("should return odd for (13)", function() {
  5. let expectedKind = 'odd'
  6. let actualKind = isOddOrEven(13)
  7. expect(expectedKind).to.be.odd(actualKind)
  8. })
  9. })
  10. console.log(isOddOrEven(15))
  11.  
  12. // КОД ЗА ТЕСТВАНЕ:
  13.  
  14.  
  15. function isOddOrEven(string) {
  16. if (typeof(string) !== 'string') {
  17. return undefined;
  18. }
  19. if (string.length % 2 === 0) {
  20. return "even";
  21. }
  22.  
  23. return "odd";
  24. }
  25.  
  26. module.exports = {isOddOrEven}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement