Task of Challenge #24
Create a function that will merge two arrays and return the result as a new array. The two arrays: [9, 8, 7, 6], [1, 2, 3, 4] .
mergeArrays has two inputs (
array2). It also does create an empty array
tempArray where the combined and merged array will be stored to.
This time you need two for loops to cover the merging process. You simply push all elements of the first array to the variable
tempArray. When this is done, you approach the second array and push also each element into
Once you’ve iterated over both arrays and all elements are stored into
tempArray you just do the return and already have it. A merged array.
The output for the code above is: