Easy 🎁🎁
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * @param {Function} fn\n * @param {Array} args\n * @param {number} t\n * @return {Function}\n */\nvar cancellable = function(fn, args, t) {\n  fn(...args);\n\n  let id = setTimeout(function run() {\n    fn(...args);\n    id = setTimeout(run, t);\n  }, t);\n\n  const cancelFn = () => clearTimeout(id);\n\n  return cancelFn; \n};\n\n/**\n *  const result = []\n *\n *  const fn = (x) => x * 2\n *  const args = [4], t = 20, cancelT = 110\n *\n *  const log = (...argsArr) => {\n *      result.push(fn(...argsArr))\n *  }\n *       \n *  const cancel = cancellable(fn, args, t);\n *           \n *  setTimeout(() => {\n *     cancel()\n *     console.log(result) // [\n *                         //      {"time":0,"returned":8},\n *                         //      {"time":20,"returned":8},\n *                         //      {"time":40,"returned":8},           \n *                         //      {"time":60,"returned":8},\n *                         //      {"time":80,"returned":8},\n *                         //      {"time":100,"returned":8}\n *                         //  ]\n *  }, cancelT)\n */\n```
['JavaScript']