-
Code // why not ? const power = ( a, b ) => Math.pow(a, b);
Test Cases const chai = require("chai"); const assert = chai.assert; chai.config.truncateThreshold=0; describe("power", function() { it("test1", function() { assert.strictEqual(power( 2,4 ), 16); }); it("test2", function() { assert.strictEqual(power( 2,3 ), 8); }); it("test3", function() { assert.strictEqual(power( 2,2 ), 4); }); it("test4", function() { assert.strictEqual(power( 2,0 ), 1); }); it("test5", function() { assert.strictEqual(power( 2, -1 ), 0.5); }); it("test6", function() { assert.strictEqual(power( 4, 0.5 ), 2); }); it("test7", function() { assert.strictEqual(power( 8, 1/3 ), 2); }); });
Output:
-
Code - // why not ?
const power = ( a, b ) => a ** b;- const power = ( a, b ) => Math.pow(a, b);
- All
- {{group.name}} ({{group.count}})
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}