const fields = [\'email\', \'password\']; const objFields = {}; fields.forEach(value => { objFields[value] = \'\'; }); console.log(objFiel
Whenever you're looking for reducing an array of values to one value, you're looking for .reduce()
.reduce()
state = { fields: fields.reduce((acc, key) => ({...acc, [key]: ''}), {}), };