I have an objects:
http ={" xxx": "#phone#","yyy": "1234", "zzz":5678 }
input= {"phone": "2", "id": "258 },
How do I find the #phone# value and replace it with 2 from input?
The #phone# key can be anything, not just "xxx".
I have an objects:
http ={" xxx": "#phone#","yyy": "1234", "zzz":5678 }
input= {"phone": "2", "id": "258 },
How do I find the #phone# value and replace it with 2 from input?
The #phone# key can be anything, not just "xxx".
You could use Object.entries() to iterate over each property of the object and then check with an if statement if the key-value is the one that you want and change it.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries
Use Object.entries() to loop over the properties of the object and then check with an if statement whether the value is the one that you want and change it to the desired value.
const entries = Object.entries(id);
entries.forEach((entry) => {
if (entries[1] === '#phone#') {
id[entry[0]] = 'SOME_VALUE';
}
});