Specify nReps with a variable name

ok i solved the problem.
it didnt work before because the first time i was defining the “a” variable was within a function. however, where i used “a” as a value for nReps was another function. thus, in the first function where i defined “a” for the first time, “a” became a local variable, instead of a global one. hence the function where we define nRep didnt recognize “a” as a variable and asked me to define it again. i did it but when you do that the second time, the two “a” s make two different local variables: in the first function, indeed it takes an integer value. but when you define “a” with “var a;” and use it as an nRep assignment right away, js goes like “what is ‘a’ anyways? it doesnt have a proper value”, and throws an error.

once you make the variable a global one by defining it outside the function (i suggest this approach if you are to use that variable in another function), you dont face this problem. otherwise, things can happen…