Assigned function to a variable,but it always returns empty string

I have the following function

//user_length() gets integer input from the user in order to determine length
//random_digit() returns 1-9 randomly
 var random_number = function (){
      let sequence = [];
      for(i = 0; i < user_length() ; i++ ){
         sequence.push(random_digit());
      }
      return sequence.join('')
    }
    
    var finalString = random_number();

whenever I call the function it behaves as it has to but when I try to use the variable, it returns an empty string, I think it’s because the function is not being called, but I don’t know how to fix that

[].join('') returns an empty string, so my guess is that when you get to the return statement in the function random_number the sequence array is still empty.

Since we can’t see the code for the user_length or random_digit functions I can’t give you much more help, but my guess is that at least one of those is not doing what you want it to do.