-
Math.pow not accepting my array values
Wierd...
Code:
narray = [[.55], [.6], [.7], [.9], [1.125], [1.4], [1.75], [1.875], [5.5]];
Nsum = 0;
for (n=0; n<=narray.length-1; n++) {
narrayn = narray[n];
Nsum += Math.pow(narrayn, -1);
}
Narrayn returns Valid, while Nsum returns NaN.
WhY? i fiddled wit this for a straight hour and i'm ripping my hair out over wut the heck i did wrong.
EDIT: really all i'm trying to do is take the reciprocal of my array variables, which i then put through a script (tested and worked) which avgs them, and then performs a function on them. Its to test whether a series of speeds at set intervals will end me up at the same place.
maximum width 300 no more maximum hieght 40 no more not interchangable
-
Senior Member
narrayn is an array (containing a single value) - Math.pow will only accept numbers.
Code:
narray = [[.55], [.6], [.7], [.9], [1.125], [1.4], [1.75], [1.875], [5.5]];
Nsum = 0;
for (n=0; n<=narray.length-1; n++) {
narrayn = narray[n];
Nsum += Math.pow(narrayn[0], -1);
}
trace(Nsum);
should work as expected.
-
asdf
Oh so when u assign a single "digit" of an array to a variable, the variable becomes a one unit array? i see!
EDIT: correct the solution works. Thx u
Last edited by taifunbrowser; 05-13-2006 at 03:24 PM.
maximum width 300 no more maximum hieght 40 no more not interchangable
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|