Is there a much organised way to merge the different sized arrays to a single one, that each block will remain as an element just to sort them easily?
I've use nested for loops but still not sure if this is a proper way to do it.
function mergeArray(parameter){
console.log(arguments.length);
let newArray = [];
for (let i = 0 ; i<arguments.length; i++){
for (let a = 0; a<arguments[i].length; a++){
newArray.push(arguments[i][a]);
}
}
return newArray.sort();
}
const shelf1 = ['apple', 'banana', 'orange', 'kiwi'];
const shelf2 = ['milk', 'egg', 'ketchup', 'sausage'];
const shelf3 = ['eggplant', 'cucumber', 'water', 'coke'];
console.log(mergeArray(shelf1, shelf2, shelf3))