Factorialize a Number 101

Tell us what’s happening:
The code is producing correct answers but the app wont accept it?
is there something wrong that i am doing?

Your code so far

function factorialize(num) {
  for (var i = 1; i <= num; i++) {
    ft = ft * i;
  return ft;


Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36.

Link to the challenge:

What I see is that the variable ft is never initialized. It must be initialized. And to avoid a future problem, remember that for these tests if declare it globally you will run into problems.

Oh am sorry … but i actually did declare the ft variable globally

i did declare the ft variable globally and it is not giving me errors but it is bot accepting the code?

The issue is that if you declare it globally, it will inherit the value from the previous test.

In general, global variables should be avoided. In general variables should have as narrow scope as they need.

1 Like

Thank you @kevinSmith … appreciate it! I got the explanation and my code works now !!