0
How can I join two arrays into one array 1stArray [1,2,3,] 2nd Array [11,22,33] The output should be [11,1,22,2,33,3]
2 Answers
0
I've already try concat it works but my result is [1,2,3,11,22,33]
0
let mergedarray = array.concat(otherArray).sort((a,b)=>{
//your logic for array order here
// a logic where 11 is chosen first before 1
// but 1 is in front of 22
})
lets see... first compare the first number, if the first number are same compare its length..
so.. cast it to string, get the first index, then compare. if same compare the .length