Added some test cases.
isEven = num => Number.isInteger(num) ? !(num & 1) : undefined;
isEven = _0x55bac8 => !(_0x55bac8 % 2);- isEven = num => Number.isInteger(num) ? !(num & 1) : undefined;
const expect = require("chai").expect; describe("Solution", function() { it("should be true for 4", function() { expect(isEven(4)).to.equal(true); }); it("should be false for 1", function() { expect(isEven(1)).to.equal(false); }); it("should be undefined for 1.5", function() { expect(isEven(1.5)).to.equal(undefined); }); it("should be undefined for NaN", function() { expect(isEven(NaN)).to.equal(undefined); }); it("should be undefined for Infinity", function() { expect(isEven(Infinity)).to.equal(undefined); }); it("should be undefined for -Infinity", function() { expect(isEven(NaN)).to.equal(undefined); }); it("should be undefined for undefined", function() { expect(isEven(undefined)).to.equal(undefined); }); });
- const expect = require("chai").expect;
- describe("Solution", function() {
- it("should be true for 4", function() {
- expect(isEven(4)).to.equal(true);
- });
- it("should be false for 1", function() {
- expect(isEven(1)).to.equal(false);
- });
- it("should be undefined for 1.5", function() {
- expect(isEven(1.5)).to.equal(undefined);
- });
- it("should be undefined for NaN", function() {
- expect(isEven(NaN)).to.equal(undefined);
- });
- it("should be undefined for Infinity", function() {
- expect(isEven(Infinity)).to.equal(undefined);
- });
- it("should be undefined for -Infinity", function() {
- expect(isEven(NaN)).to.equal(undefined);
- });
- it("should be undefined for undefined", function() {
- expect(isEven(undefined)).to.equal(undefined);
- });
- });