Ad
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    When I did the kata the simple test cases seemed to be missing. Might I suggest something like:

    describe('functionality tests', function() {
      function example(a, b) {
        return a + b;
      }
      
      var cached = cache(example);
      
      it('should return correct results', function() {
        Test.assertEquals(cached('foo', 'bar'), 'foobar', 'The cache function returned incorrect results');
        Test.assertEquals(cached('foo', 'bar'), 'foobar', 'The cache function returned incorrect result when called twice');
        Test.assertEquals(cached('foo', 'baz'), 'foobaz', 'The cache function returned incorrect results');
      });
    }
    
  • Custom User Avatar

    This got a little fancy. I used a trie like structure to cache results. This would allow me to store less data if there were many similiar function calls. I also wanted to optimize the hashing for arguments and considered storing primative values directly.

  • Custom User Avatar