Move History

Fork Selected
  • Functions
    Control Flow
    Basic Language Features
    Fundamentals
    Description

    Write Memoize function.

    Memoize is function that take as argument function and return another function.

    This returned function should call original function with the same arguments, but it should never call this function with exact the same arguments.

    It should just return cahed result instead.

    Code
    function memoize(func) {
      return (...args) => {
        // your function
      };
    }
    Test Cases Failed
    // TODO: Replace examples and use TDD development by writing your own tests
    
    // These are some CW specific test methods available:
    //    Test.expect(boolean, [optional] message)
    //    Test.assertEquals(actual, expected, [optional] message)
    //    Test.assertSimilar(actual, expected, [optional] message)
    //    Test.assertNotEquals(actual, expected, [optional] message)
    
    // NodeJS assert is also automatically required for you.
    //    assert(true)
    //    assert.strictEqual({a: 1}, {a: 1})
    //    assert.deepEqual({a: [{b: 1}]}, {a: [{b: 1}]})
    
    // You can also use Chai (http://chaijs.com/) by requiring it yourself
    // var expect = require("chai").expect;
    // var assert = require("chai").assert;
    // require("chai").should();
    
    describe("Solution", function(){
      it("should test for something", function(){
        Test.assertEquals("actual", "expected", "This is just an example of how you can write your own TDD tests");
      });
    });