Sorry, my bad. Fixed my solution and added some more tests.
const isDivisible = (n, x, y) => Number.isInteger(n/x) && Number.isInteger(n/y)
isDivisible = (n, x, y) => !(n % x || n % y)- const isDivisible = (n, x, y) => Number.isInteger(n/x) && Number.isInteger(n/y)
const chai = require("chai"); const assert = chai.assert; chai.config.truncateThreshold=0; describe("Basic tests", () => { it("Fixed Tests", () => { assert.strictEqual(isDivisible(3,3,4),false); assert.strictEqual(isDivisible(12,3,4),true); assert.strictEqual(isDivisible(8,3,4),false); assert.strictEqual(isDivisible(48,3,4),true); assert.strictEqual(isDivisible(80,40,10),true); assert.strictEqual(isDivisible(1,0,0), false); assert.strictEqual(isDivisible(1,1,3), false); assert.strictEqual(isDivisible(9e19,1,3), true); assert.strictEqual(isDivisible(1,1,9e18), false); }); });
- const chai = require("chai");
- const assert = chai.assert;
- chai.config.truncateThreshold=0;
- describe("Basic tests", () => {
- it("Fixed Tests", () => {
- assert.strictEqual(isDivisible(3,3,4),false);
- assert.strictEqual(isDivisible(12,3,4),true);
- assert.strictEqual(isDivisible(8,3,4),false);
- assert.strictEqual(isDivisible(48,3,4),true);
- assert.strictEqual(isDivisible(80,40,10),true);
- assert.strictEqual(isDivisible(1,0,0), false);
- assert.strictEqual(isDivisible(1,1,3), false);
- assert.strictEqual(isDivisible(9e19,1,3), true);
- assert.strictEqual(isDivisible(1,1,9e18), false);
- });
- });