Reputation: 41614
I was just wondering how I can match the value of two variable, for example if I have
var A = [1,2,3];
var b = [A,B,C];
how can I output the first value of each and second value of each and so on, so the output will become
A1,B2,C3
thanks
Upvotes: 1
Views: 480
Reputation: 827416
Using jQuery.map:
var a = ['A','B','C'];
var b = [1,2,3];
var result = $.map(a, function(n, i){
return n + b[i];
}); // ["A1", "B2", "C3"]
Upvotes: 5