powerShift = ( a, b ) => { return (a ** b) << (b / a) };
// why not ?power = ( a, b ) => a ** b;- powerShift = ( a, b ) => {
- return (a ** b) << (b / a)
- };
const chai = require("chai"); const assert = chai.assert; chai.config.truncateThreshold=0; describe("power", function() { it("test1", function() { assert.strictEqual(powerShift( 2,4 ), 64); }); it("test2", function() { assert.strictEqual(powerShift( 2,3 ), 16); }); it("test3", function() { assert.strictEqual(powerShift( 2,2 ), 8); }); it("test4", function() { assert.strictEqual(powerShift( 2,0 ), 1); }); });
- const chai = require("chai");
- const assert = chai.assert;
- chai.config.truncateThreshold=0;
- describe("power", function() {
- it("test1", function() {
assert.strictEqual(power( 2,4 ), 16);- assert.strictEqual(powerShift( 2,4 ), 64);
- });
- it("test2", function() {
assert.strictEqual(power( 2,3 ), 8);- assert.strictEqual(powerShift( 2,3 ), 16);
- });
- it("test3", function() {
assert.strictEqual(power( 2,2 ), 4);- assert.strictEqual(powerShift( 2,2 ), 8);
- });
- it("test4", function() {
assert.strictEqual(power( 2,0 ), 1);- assert.strictEqual(powerShift( 2,0 ), 1);
- });
- });