Answers for "how to make two arrays one javascript"

PHP
67

combine two arrays javascript

let arr1 = [0, 1, 2];
let arr2 = [3, 5, 7];
let primes = arr1.concat(arr2);

// > [0, 1, 2, 3, 5, 7]
Posted by: Guest on February-02-2020
0

from array create two arrayjavascript

//If you find something better, please, let me know :(
let arr = [[1,2],[3,4],[5,6]]
let [arr1, arr2] = [[], []]
arr.map((e) => { arr1.push(e[0]); arr2.push(e[1]) })
console.log(arr1,arr2) // [[1,3,5],[2,4,6]]
Posted by: Guest on April-18-2021

Code answers related to "how to make two arrays one javascript"

Browse Popular Code Answers by Language