Simple solution
\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\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  var timerId;\n  var time = 0;\n  var result = [];\n\n  function executeFn() {\n    var returnedValue = fn.apply(null, args);\n    result.push({ time: time, returned: returnedValue });\n    time += t;\n  }\n\n  function cancelFn() {\n    clearInterval(timerId);\n  }\n\n  executeFn();\n  timerId = setInterval(executeFn, t);\n\n  return cancelFn;\n};\n\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']