Let's say I have an array like this:
var myArray = [
['a', 'b'],
['c', 'd']
]
How do I concatenate this two-dimensional array so I get this as a result:
['ab', 'cd']
Just use Array.prototype.map().
var newArray = myArray.map(function (item) {return item.join('');}); //["ab", "cd"]
http://jsfiddle.net/6bw65xj4/1/
var tmp = '',
newArray = [],
myArray = [
['a', 'b'],
['c', 'd']
];
for(var i=0; i<myArray.length; i++){
for(var j=0; j<myArray[i].length; j++) {
tmp = tmp + myArray[i][j];
}
newArray.push(tmp);
tmp = ''
}
console.log(newArray);