In javascript pls
Challenge 2 – Fibonacci Create a function called FibonacciMaker that takes in a single number and returns an array of that size filled with Fibonacci numbers (starting with 0).
Use case: var fibArray = FibonacciMaker()
Challenge 4 – Random Integer in Range Write a function to return a random integer between a minimum value and maximum value.
var ival = IntRandomRange(, );
Hi, as per limited time i have solved only first one, so post other question again.
if you have any problem in solution do comment I'll be happy to help you.
code:
// your code goes here
var fibArray = function (n)
{
if (n===1)
{
return [0, 1];
}
else
{
var s = fibArray(n - 1);
s.push(s[s.length - 1] + s[s.length - 2]);
return s;
}
};
//console.log(fibArray(8));
//console.log(fibArray(9));
console.log("Enter your number");
response = readline()
//i subtract one because need numbers from zero onwards
console.log(fibArray(response-1));
Get Answers For Free
Most questions answered within 1 hours.