dimanche 6 juillet 2014

Connecting elements in separate arrays


Vote count:

0




I'm looking to connect two arrays together, sort of. I have two arrays, and want the elements of them to be sort of 'combined'.


So, let's say I have a scanner. It gives me a value for each element in array1 (like US$). I want it to return something (like a string, "this product is selling for cheap!") if that value for each element is less than or equal to the value in array2.


I'd only want it to link one item in an array to another in the same position.


Two arrays (mentioned above, briefly):



var array1 = [741, 451, 54188, 5847, 5418, 54944, 310, 541, 7451, 10211, 113, 9115, 62, 2841, 52482481, 24];
var array2 = [15, 418, 488, 130000, 8482, 55, 16, 14, 2546, 651, 4521, 11, 54, 659, 542, 1152];


So, 741 would be linked to 15, 451 to 418, 54188 to 488, etc.


After they were "linked", I would be able to see if the value (by value, I mean what my scanner finds for each one) for the element in array1 is equal to/less than the value for that element in array2.


For example, putting 741 into my scanner returns 16. This is not less than 15, so wouldn't return anything. - However, putting 451 into my scanner returns 417. This is less than 418, so it would return "this product is selling for cheap!"


I hope this made sense.



asked 43 secs ago






Aucun commentaire:

Enregistrer un commentaire