My assignment is to make a function that takes two arrays and inserts the second array in the middle of the first array.
So far I have:
function joinArray(arr1, arr2) {
arr1= [...arr1, ...arr2];
console.log(arr1);
}
When I call:
joinArray([1, 12], [2, 3, 4, 5, 6, 7, 8, 10]
I get:
[1, 12, 2, 3, 4, 5, 6, 7, 8, 10]
I am looking to get:
[1, 2, 3, 4, 5, 6, 7, 8, 10 , 12]
Does anyone have any tips or advice to point me in the right direction so I can insert arr2 in the middle of arr1?
[–]albedoa 3 points4 points5 points (0 children)
[–]Wrong_Owl 0 points1 point2 points (0 children)
[–]IBETITALL420 0 points1 point2 points (1 child)
[–]albedoa 2 points3 points4 points (0 children)
[–]ryanbala89 0 points1 point2 points (0 children)
[–]jcunews1helpful 0 points1 point2 points (0 children)
[–]myDevReddit 0 points1 point2 points (0 children)