Whats the most elegant way of mapping a list into a list of dictionaries n at a time using react?
["a", "b", "c"] => [{0:"a", 1:"b"}, {0:"c"}]
Whats the most elegant way of mapping a list into a list of dictionaries n at a time using react?
["a", "b", "c"] => [{0:"a", 1:"b"}, {0:"c"}]
 
    
    You can use reduce for this:
['a', 'b', 'c'].reduce((acc, currentValue, currentIndex) => {
  acc.push({ [currentIndex]: currentValue });
  return acc;
}, []);
Here's a great Twitter post that explains how various array methods work:
