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
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!