Array.prototype.concatbeginnerconst a = [1, 2]
const b = [3, 4]
a.concat(b) // β [1, 2, 3, 4]Use concat() to merge two arrays into a new one without mutating either original.
Array.prototype.concat() returns a new array that contains the elements of the original array followed by the elements of the provided arrays or values. The original arrays are not modified.
Challenge: Implement joinArrays(a, b) that returns a new array with all elements of a followed by all elements of b using .concat().
joinArrays([1, 2], [3, 4]) // β [1, 2, 3, 4]
joinArrays([], [1]) // β [1]