[Solved] How can I retrieve data from two different const and put it in a for [closed]

You can create a method getObjByKey to find in the provided arr array the object that contains key property and use Destructuring assignment the get the value Code: const getObjByKey = (key, arr) => arr.find((obj) => Object.entries(obj).find(([k, v]) => key === k)); Then you can do: const { data2 } = getObjByKey(‘data2’, date1); const { … Read more