`Challenge`

`: Find out the factorial of given number.`

**Example:**

Input: 4

Output: 24

**Solution:**

function factorial(n) {

if (n > 1) {

return factorial(n-1) * n;

}

else {

return 1;

}

}

console.log(factorial(4));

**Try it Yourself:**

`Challenge`

`: Find out the factorial of given number.`

**Example:**

Input: 4

Output: 24

**Solution:**

function factorial(n) {

if (n > 1) {

return factorial(n-1) * n;

}

else {

return 1;

}

}

console.log(factorial(4));

**Try it Yourself:**

`Challenge: find out the Fibonacci series for the given number.`

**Example:**

Input: 6

output: 0,1,1,2,3,5,8.

`Solution:`

function fibArray(n) {

`let arr = [];`

`arr[0] = 0;`

`for (let x = 1; x <= n; x++) {`

`arr.push( (x < 2) ? 1 :`

`arr[x - 1] + arr[x - 2]`

`);`

`}`

`return arr;`

`}`

console.log(fibArray(6));

**Try it yourself:**