In this exercise, I think there is mistake in first code challenge, because it gave this code solution:
// Write function below
const factorial = n => {
let result = 1;
for (let i=n; i>0; i--) {
result *= i+1;
}
return result;
}
Instead of this:
// Write function below
const factorial = n => {
let result = 1;
for (let i=n; i>0; i--) {
result *= i;
}
return result;
}
My Solution:
// Write function below
let factorial = (number) =>{
let fact = 1;
for(let i=number;i>0;i--){
fact = fact*i;
}
return fact;
}
console.log(factorial(1));