Javascript recursion approach, but failed at speed.
\nvar arrayNesting = function(nums) {\n    let len = nums.length\n    let i = 0\n    let maxLength = 0\n    while (i < len) {\n        var setArr = []\n        
```\nvar arrayNesting = function(nums) {\n    let len = nums.length\n    let i = 0\n    let maxLength = 0\n    while (i < len) {\n        var setArr = []\n        \n        const recursionBaby = n => {\n            if(setArr.indexOf(nums[n]) == -1) {\n                setArr.push(nums[n])\n                recursionBaby(nums[n])   \n            }\n        }\n\n        recursionBaby(i)\n\n        if(setArr.length > maxLength) {\n            maxLength = setArr.length\n        }\n\n        i++\n    }\n\n\n    return maxLength\n}\n```\n\nhow could i make it faster?
[]