-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
  • 379
  • 2
  • 14

1 Answers1

1

Try to use .map():

  arr.map(elem => {
    elem.read = true;
    return elem;
  })
AlTheLazyMonkey
  • 1,051
  • 1
  • 7
  • 19