0

I've got a question, how to get a value to find it by id?

Eg I got something like: "{section,249013: 'some value', section,244242: 'another value'}" and I need to put it into the object

const someObject = [
section: {
 id: 249013,
 options: [someArray],
values: I need to insert value here
},
section: {
 id: 244242,
 options: [someArray],
values: I need to insert another value here
}

]

Is there any way to do it?

๖JoJo
  • 55
  • 1
  • 8
  • Let arrayofobjects = Object.keys(yourObjectThatContainsObjects) and declare a varibale lets say targetObject and do as follow:1-arrayOfObjects.forEach(key=>{if(yourObjectThatContainsObjects[key][id]===wantedId){targetObject = yourObjectThatContainsObjects[key]}). Something like that as i understood – Jad Al-Hamwi Mar 24 '21 at 12:04
  • I got to convert into id: value the object I got and then somehow place it into the object below. – ๖JoJo Mar 24 '21 at 12:19
  • it's quite unclear can you clarify a bit more?i suppose that you want to conditionally add a new object according to the id you want to search for, into the bigObject which's containing all other objects right? – Jad Al-Hamwi Mar 24 '21 at 13:03
  • I get from backend object which in properties has sectiond,id: values. I have to seperate them and put them into right place into my object which I showed below. I have to put those values into the properties values in the object of someObject. – ๖JoJo Mar 24 '21 at 13:12

0 Answers0