Reversing the multiplication

I am following along with this challenge and I would like to expand my knowledge.

function toMulti(multi, ...theArgas){
return theArgas.map(function(elements){
    return multi * elements;
});
}

var arr = toMulti(3,4,6,8);
console.log(arr);

I have tried various ways to reverse the multiplication process to have the multiplier to be the last number and multiply it with rest of the numbers

Here is what I have tried but did not work :slightly_frowning_face:

I used indexing to start with last number

function toMulti(multi[multi.lenght-1], ...theArgas){
return theArgas.map(function(elements){
// or return multi[multi.lenght-1] * elements;
    return multi * elements;
});
}

var arr = toMulti(3,4,6,8);
console.log(arr);

I also tried various combination like here:

const prod(...ar){
return ar.reduce((...ar) => n.lenght-1, 1);

}
console.log(prod(2,3,4,5));

Any help!

I don’t know what you want to do with that, but it doesn’t seem quite right

so you want to have the last number be the multiplier?

you need to do some weird stuff there, as there is not an easy cut out way, because that makes the multiplier be in an always different position

function toMulti (...numbers) {
  let factors = numbers.slice(0, -1) // this takes the whole array without last element
  let multiplier = numbers.slice(-1) // this copies last element of the array
}

something like that

you can find many ways but nothing will be as easy as to have the parameters as (factor, ...numbers)