PLS exeplain how this code is working

“The code below so far”
Could you explain how the code below works?
and Thanks all you guys :smile:

function multiply(multiplier, ...theArgs) {
  return theArgs.map(function(elements) {
    return multiplier * elements;
  });
}

Hello there,

I would explain it with what I would have done to make this function:

function multiply(multiplier, vec) {
  return vec.map(element => multiplier*element);
}
multiply(3, [1, 2, 3, 4]); // returns: [3, 6, 9, 12]

If that is not too clear either, then I suggest you take a look at the main syntax used in the code you mentioned:

Hope this helps

1 Like