Better than 92% solutions || Easy Solution || Accepted ✅🔥
\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    fn(...args)\n    const intervalId = setInterval(()=>{\n        fn(...args)\n    },t)\n    const cancelFn = () => clearInterval(intervalId);\n    return cancelFn;\n};\n\n/**\n *  const result = [];\n *\n *  const fn = (x) => x * 2;\n *  const args = [4], t = 35, cancelTimeMs = 190;\n *\n *  const start = performance.now();\n *\n *  const log = (...argsArr) => {\n *      const diff = Math.floor(performance.now() - start);\n *      result.push({"time": diff, "returned": fn(...argsArr)});\n *  }\n *       \n *  const cancel = cancellable(log, args, t);\n *\n *  setTimeout(cancel, cancelTimeMs);\n *   \n *  setTimeout(() => {\n *      console.log(result); // [\n *                           //     {"time":0,"returned":8},\n *                           //     {"time":35,"returned":8},\n *                           //     {"time":70,"returned":8},\n *                           //     {"time":105,"returned":8},\n *                           //     {"time":140,"returned":8},\n *                           //     {"time":175,"returned":8}\n *                           // ]\n *  }, cancelTimeMs + t + 15)    \n */\n```
['JavaScript']