Build a Factorial Calculator - Build a Factorial Calculator

Tell us what’s happening:

it’s giving me error on all steps even on num variable, as you see I’ve declared it.
can you tell me what’s wrong here?

Your code so far

let num = 5;

function factorialCalculator(number){
const result = 1;
for(let i = 1; i <= number; i++){
result = result * i;
}
return result
}

let factorial = factorialCalculator(num);
let resultMsg = `Factorial of ${num} is ${factorial}`;
console.log(resultMsg);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36

Challenge Information:

Build a Factorial Calculator - Build a Factorial Calculator

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-factorial-calculator/66c07238b01053abaf812065.md at main · freeCodeCamp/freeCodeCamp · GitHub

You are trying to change the value of a const variable.

Please go through How Do let and const Work Differently When It Comes to Variable Declaration, Assignment, and Reassignment? and then try the lab again.

Hi @Ruhollahbayani,

Going forward, please pay attention to the information in your console:

TypeError: Assignment to constant variable.

In this case, the only variable declared as a const is result, so you could have easily pinpointed the issue yourself.

Happy coding

how could i not see it, thank you