JSFiddle - React, Tailwind, and code Playground

by igalst

JavaScript

const arr = [1, 2, 3, 4];

// 1 + 2 + 3 + 4
const result = arr.reduce((acc, item, index) => {
	acc['field'+ index] = item;
  return acc;
}, {});

console.log(result);