-1

How can i access the BookProperties Array(24) and update the Book-EngineType with the value SG to something like EngineType1

enter image description here

what i expect to get within setState() is Book-EngineType to be of value EngineType1 and not SG.

Brhaka
  • 1,622
  • 3
  • 11
  • 31
David Zagi
  • 1,383
  • 2
  • 10
  • 18
  • Duplicate? -> https://stackoverflow.com/questions/6439915/how-to-set-a-javascript-object-values-dynamically – daddygames Jul 30 '19 at 11:46

1 Answers1

0
let bookProperties = [
    {name:'bookallowtostorehistory', val:'manual'},
    {name:'Book-EngineType', val:'SG'}
];

bookProperties.forEach(function(el) {
    if (el.name == 'Book-EngineType') {
        el.val = 'EngineType1';
    }
})
barbsan
  • 3,418
  • 11
  • 21
  • 28
SHUBHAM SINGH
  • 371
  • 3
  • 11
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/23664466) – martin Jul 30 '19 at 15:43
  • 1
    Um, @martin, this post does not contain any links. – pppery Jul 31 '19 at 03:43