playing around with memoization in javascript