I am trying to solve one of the problem on codewars. The problem is as below:
In mathematics, the Fibonacci numbers are in the following integer sequence, called the Fibonacci sequence, and characterized by the fact that every number in it is the sum of the two preceding ones:
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ... Implement function getFibonacci(n) which will return the string representation of number on n position on the Fibonacci sequence.
I have worked out my codes, but my code can only past the test when the tested numbers are small and failed all tests when large numbers involved and getting the error message like "Expected: '30010821454963453907530667147829489881', instead got: '3.001082145496346e+37'". In addition, I have tried to add toNotExponential() or expandExponential() at the end of my return statement to help show the full number, however, either of the code works as I keep getting errors saying"toNotExponential() is not a function" or " expandExponential() is not a function". Not sure what to do, please help. My code as below...
function getFibonacci(n) {
var arr= [1,1];
var len = arr.length;
while(len<n){
arr.push(arr[len-1]+arr[len-2]);
len++;
}
return (arr[len-1]+"").toNotExponential();
}