{"ScriptPreparationCode":null,"TestCases":[{"Name":"Recursive","Code":"function fibonacciRecursive(num) {\r\n if (num === 0) return 0;\r\n else if (num === 1) return 1;\r\n else return fibonacciRecursive(num - 1) \u002B fibonacciRecursive(num - 2); //i[n] = i[n-1] \u002B i[n-2]\r\n}\r\n\r\nfibonacciRecursive(10)","IsDeferred":false},{"Name":"Memoization","Code":"function fibonacciRecursiveObjDefault(num, cache = {}) {\r\n //base case as normal\r\n if (num === 0) return 0;\r\n else if (num === 1) return 1;\r\n if (cache[num]) return cache[num]; //retrieve cached data if exists\r\n let output = fibonacciRecursiveObjDefault(num - 1, cache) \u002B fibonacciRecursiveObjDefault(num - 2, cache); //recursive call as normal\r\n cache[num] = output; //store output into the cache for future use\r\n \r\n return output;\r\n}\r\n\r\nfibonacciRecursiveObjDefault(10)","IsDeferred":false}]}