Help to solve a question

Hi All,

I had a question

how would you solve this:

Update the transform function such that it works with n number elements and also same function works for string element ?


const input = [
               [2,3,5], 
               [2,4],
               [7,8,9]
              ];
const transform = (input, callback) => {
   return callback([input[0],input[1]]);
 }

const output = transform(input, (elm1, elm2) => {
   return elm1.concat(elm2);// should return [7,8,9,2,4,2,3,5]
});

const input2 = ["hello", "welcome", !];

const output2 = transform(input2, (elm) => {
   return elm.toUppercase(); // should return HELLO WELCOME !
});

Thank you all

Comments (0)