Very Easy Solution:  Interval Cancellation
Intuition\nThe cancellable function is designed to execute a given function, fn, repeatedly at regular intervals specified by t. It also provides a way to cance
# Intuition\nThe cancellable function is designed to execute a given function, fn, repeatedly at regular intervals specified by t. It also provides a way to cancel this repetition using the returned cancelFn. This can be useful for scenarios where you want to create periodic tasks that can be canceled or stopped when needed.\n\n# Approach\n1. The function fn is initially executed with the provided args.\n2. A timer is set using setInterval to repeatedly execute fn with args every t milliseconds.\n3. The cancelFn is defined as a function that clears the timer using clearInterval, effectively stopping the repeated execution of fn.\n\n# Complexity\n- Time complexity:\no(1)\n\n- Space complexity:\no(1)\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    let timer = setInterval(()=> fn(...args),t);\n\n    let cancelFn = () => clearInterval(timer)\n    return cancelFn;\n};\n\n/**\n *  const result = []\n *\n *  const fn = (x) => x * 2\n *  const args = [4], t = 35, cancelT = 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(() => {\n *     cancel()\n *  }, cancelT)\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 *  }, cancelT + t + 15)    \n */\n```
['JavaScript']