Move History

Rooted by: Power function
Fork Selected
  • 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);
      });
      
      
    });
    
    
    
  • Code
    • // why not ?
    • const power = ( a, b ) => a ** b;
    • const power = ( a, b ) => Math.pow(a, b);