My array variables are as follows:
const gumBrands = ['orbit', 'trident', 'chiclet', 'strident'];
const mintBrands = ['altoids', 'certs', 'breath savers', 'tic tac'];
Presented below is a function that utilizes these arrays as input parameters:
function shallowCopy (arrOne, arrTwo) {
if (arrOne.constructor === 'Array'){
return [...arrOne, ...arrTwo];
}
else {
console.log('test this');
}
}
shallowCopy(gumBrands, mintBrands)
I anticipate the code to produce the following output:
[ 'orbit',
'trident',
'chiclet',
'strident',
'altoids',
'certs',
'breath savers',
'tic tac' ]
However, instead of returning the expected result, the code executes the else statement and outputs: test this
What mistake am I making here?