loading...

re: Daily Coding Problem #2 VIEW POST

TOP OF THREAD FULL DISCUSSION
re: I did something very similar to this. I realised quickly that if any of the numbers in the array are repeated, the totals don’t come out right. I h...
 
const array = [1, 2, 3, 4, 5];

const updated = array.map((ignored, currentIndex) =>
  array.reduce((accum, value, index) => {
    if (currentIndex === index) return accum
    return accum * value;
  }, 1));
Code of Conduct Report abuse