You can use a function similar to the following:
On Friday, May 23, 2014 1:32:20 PM UTC-4, I.O.S wrote:
-- function subtractArrayValues(arr1, arr2) {
var i,
arr3 = [];
for(i=0;i<arr1.length;i++) {
arr3.push(arr1[i] - arr2[i])
}
return arr3;
}
Array3 = subtractArrayValues(Array1, Array2);
On Friday, May 23, 2014 1:32:20 PM UTC-4, I.O.S wrote:
Hi All,I have 2 arrays and I would like to subtract the contents of one from the other and store in another array.Ex:Array1 = [10, 15, 25]Array2 = [5, 12, 9]Results should beArray3 = [5, 3, 16]
You received this message because you are subscribed to the Google Groups "JavaScript Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to javascript-information+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.