There is a variable var name = name(); Runs the function:

 function name(){ var random = WScript.CreateObject("System.Random"); var count_lit = random.Next_2(2, 10); var name_i; for (var i = 0; i < count_lit; i++){ name_i += name_builder(name_i); } return name_i; } 

In which redirection to the function:

 function name_builder(name){ var random = WScript.CreateObject("System.Random"); var number_or_litr = random.Next_2(1, 2); // 1 - litr; 2 - number if(number_or_litr == 1){ var abets = random.Next_2(1, 26); var litera; switch(abets){ case 1: litera = "a"; ... case 26: litera = "z"; }; var Big_or_mini = random.Next_2(1, 2); // 1 - big; 2 - mini if(Big_or_mini == 1){ name+= litera.toUpperCase(); } else{ name+= litera; } } else{ name+= random.Next_2(0, 9).toString(); } return name; } 

The task of the script is to give the "Random" name. An error occurs when starting the script

"String: 101" is my variable reference var name = name()
"Symbol: 3"
"Error: The presence of the object is assumed"

Twisting - turning, but I can not understand. Thank!

  • 2
    Do not rush such pictures, but it may not help =) - MaximPro
  • Do not upload so much code. Obviously, there is enough string where there was an error and the function name() declarations - Pavel Mayorov
  • @MaximPro I’m not sending :) (I'll keep it in mind) - Brave_Lime
  • @PavelMayorov A bit corrected - Brave_Lime

1 answer 1

The error "Object is assumed to occur " occurs when you try to call as a function or access a property with an undefined value.


Specifically, in your case, the problem is that you name the variable in the same way as the function. Variables and functions reside in a common namespace.

So when you write name() , this same name is not a function, but a variable. The one that you have not yet initialized, and therefore undefined there. Hence the error.

Name the variable differently and you will be happy.

  • Pavel, merci! :) - Brave_Lime