[tw] Re: Javascript or jQuery - compare / subtract (2) arrays, output to a 3rd array?

2010-04-27 Thread Mike
I think I am missing something (thank you in advance for your patience) My Attempt: script var ara1 = ['a','b','c','d','e']; var ara2 = ['c','e']; function ArraySubtract(ara1,ara2) { var aRes = new Array() ; for(var i=0;iara1.length;i++) { if( ! (ara2.contains(ara1[i]) )) {

[tw] Re: Javascript or jQuery - compare / subtract (2) arrays, output to a 3rd array?

2010-04-27 Thread Mark S.
Hi Mike, The top part of the code defines the function, but the variable names are for its internal use, not yours. Perhaps I should have used demonstration arguments with different names than those being passed. In practice, you'd put the function inside a systemConfig tiddler and then invoke it

[tw] Re: Javascript or jQuery - compare / subtract (2) arrays, output to a 3rd array?

2010-04-27 Thread Mike
Thank You, it seems very clear to me now that I had a function, and I was not invoking it anywhere. . . (**banging head on desk**) I appreciate you taking the time to explain this to me. I am planning on using this in a macro, but I have developed the habit (possibly a bad habit?) of breaking

[tw] Re: Javascript or jQuery - compare / subtract (2) arrays, output to a 3rd array?

2010-04-26 Thread Mark S.
Hi Mike, Just to clarify -- that is what the function I posted does ;-) Mark On Apr 25, 5:26 pm, Mike eris...@gmail.com wrote: I think that may be it (or very close) i.e. ara1 = [a,b,c,d,e] ara2 = [c,e] aRes = [a, b, d] -- You received this message because you are subscribed to the

[tw] Re: Javascript or jQuery - compare / subtract (2) arrays, output to a 3rd array?

2010-04-25 Thread Mark S.
I guess you mean a method to produce an array by removing all items from array 1 that are not in array 2 ? Something like this? function ArraySubtract(ara1,ara2) { var aRes = new Array() ; for(var i=0;iara1.length;i++) { if( ! (ara2.contains(ara1[i]) )) { aRes.push(ara1[i]) ; }

[tw] Re: Javascript or jQuery - compare / subtract (2) arrays, output to a 3rd array?

2010-04-25 Thread Mike
I think that may be it (or very close) i.e. ara1 = [a,b,c,d,e] ara2 = [c,e] aRes = [a, b, d] I tried to google a answer, but without the proper terminology I did not get any usable results. Thank You for the feedback, Mike On Apr 25, 5:41 pm, Mark S. throa...@yahoo.com wrote: I guess you