Say I have an array like this:
var myArray = [ ['a', 'b'], ['c', 'd'] ]
How to combine this two-dimensional array, so I get this as a result:
['ab', 'cd']
Just use it Array.prototype.map().
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);
Source: https://habr.com/ru/post/1607268/More articles:java.lang.NullPointerException: attempt to call the virtual method 'java.lang.String android.net.Uri.getScheme ()' - javaHow to use Process.Start () with unicode-Symbols (for example, 😜) - c #How to show facebook profile picture on Android navigator? - androidmultiple processors registering in a single rotate file - pythonCounting and displaying duplicates across multiple fields - sqlComparing two pairs of 4 variables and returning the number of matches? - performanceWhere can I find column.status syntax information? - gitРеализовать Google-Play-Music как анимацию (спектр 3 бара рядом с элементом списка воспроизведения) - androidАрхитектура для множественных вызовов API Использование jQuery и Javascript - jsonSugarOrm: order related table - androidAll Articles