javaScript reduce() function and the rest parameter

Ok, here’s the question. I’m trying to write a function that can take one or more arrays as an argument/arguments and apply the reduce() function to them. The dilemma is that the rest parameter method won’t work when only one array is passed as an argument due to the fact that it stores the arguments in an array that can be accessed inside the function. This means that the function just returns the array since it’s an array inside an array at that point. If two or more arrays are passed, then reduce() assesses each array and the the values are added. Any idea how to get around this?

it is difficult if you don’t give examples of input and output

but try to look at reduce documentation and how to set a starting value for the accumulator

What is the expected input and output? And what have you tried already?

Ok, here’s the code:
let greet = [“Hello”, " World!"];
let where = [" I’m", " here!!"];
let concStr = (…a) => a.reduce((b, c) => b+c);

With this:
concStr(greet, where);
“Hello World I’m here!!”

[‘Hello’, ’ World’]


[’ I’m’, ’ here!!’]

Is there a way to get the function to return a string instead of an array if only one argument is passed and still be able to accept multiple arguments?

Ok. I found an answer.
the array.flat function does the trick:
let greet = [“Hello”, " World];
let where = [" I’m", " here!!"];
let strConc = (…a) =>{
return a.flat().reduce((b, c) => b+c);
this does the trick.