javascript - TypeError: Cannot call method "<method>" of undefined, when defining a function, sees parameter as undefined -


i'm trying write javascript function google script, keep getting error:

typeerror: cannot call method "<method>" of undefined

when call methods on arguments of function. here code below:

function rolldice(dice) {   var d_ind = dice.indexof('d');   var die_num = number(dice.substr(d_ind,0));   var die = number(dice.substr(d_ind + 1, dice.length()));   var value = 0;   (var = 0; < die_num; i++) {     value += math.floor((math.random() * die) + 1);   };   return value; }; 

it expected dice defined string when argument of function, doesn't make sense me.

could explain me i'm doing wrong? or if error tends crop when using google's script editor in general.

edit: people have told me issue calling function on not string, script have in code block, , not call function anywhere.

yet when running script (which shouldn't other define function , never use it), still error

edit 2: looks running function within google script editor cause little wonky, , try run lines of functions if not in functions, , treat arguments undefined variables.

but doesn't affect if script works in google sheet or not


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -