-2

I have an array of object as seen below:

const arr = [
{
    content: 'string',
    read: true
},
{
    content: 'string',
    read: false
},
{
    content: 'string',
    read: false
},
]

How would I edit the array and make all the read properties set to true?

svoruganti
  • 523
  • 1
  • 3
  • 25

1 Answers1

1

Try to use .map():

  arr.map(elem => {
    elem.read = true;
    return elem;
  })
AlTheLazyMonkey
  • 1,190
  • 1
  • 8
  • 20