Simple Solution with explanation of the program and approach to solve the problem step by step
IntuitionUnderstand the given condition and think the logic to the given problem and the return value.ApproachSimpliy it is a problem which we have to cancel th
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Understand the given condition and think the logic to the given problem and the return value.
# Approach
<!-- Describe your approach to solving the problem. -->
Simpliy it is a problem which we have to cancel the interval which we are created.
# Problem breakdown
- The problem is simple that we have to create a funcion called `cancelFn` which cancel the interval we set.
- First we have to call `fn(...args)` with some arguments.
- After that `fn` function call after every interval of time repeatedly until `cancelFn` called.
# Program breakedown
- We have function called a `cancellable` which accept the arguments `args`, `fn` function, `t` time. And return `cancelFn`.

- As per the problem we call the `fn(...args)` function with passing the arguments.

- Now lets create a function called `cancelFn` which cancle the interval that we are going to set.

- In `cancelFn` we using the `clearInterval(inteval)` where `clearInterval` which clear the inteval we set and `interval` is a variable that store the return value from the `setInterval()`.

- Lets create a interval by `setInterval()` with arrow function `() => { fn(...args) }`which call the `fn` function after each `t` time which return a value that stored in the `interval` variable which we use to cancle the interval.

- `return cancelFn` call the `cancelFn` which stop the execution of the `fn` and return it.
# Complexity
- Time complexity: O(1)
The initial call to `fn(...args)` is O(1) since it executes once immediately.
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity: O(1)
The space complexity is O(1) because the function uses a fixed amount of space regardless of the input size
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```javascript []

var cancellable = function( fn, args, t) {

    fn( ...args)

    let cancelFn = () =>{

        clearInterval( interval)
    }

    let interval = setInterval(()=>{

        fn( ...args)
    }, t)

    return cancelFn
};


```
['JavaScript']