JSFiddle - React, Tailwind, and code Playground
by Fabio Biondi
JavaScript
// const array = [3, 2, 4]; //8, 12, 6
const array = [1, 2, 3, 4, 5]; //8, 12, 6
const result = array.map((user, index) => {
return array.reduce((acc, curr, idx) => {
const total = idx === index ? acc || 1 : acc * curr;
console.log(index, idx, acc, curr, total)
return total;
}, 1)
})
console.log(result)