I am getting data something like this
{16: {email: '[email protected]', name: 'Tom', seq: 16}, 50: {email: '[email protected]', name: 'Boy', seq: 50}}
I want to change it to
{16: {email: '', name: 'Tom', seq: 16}, 50: {email: '', name: 'Boy', seq: 50}}
for just reset.
It is not an array, so I am kinda lost.
key values in the object are dynamic, so cannot just do like
const obj = {16: {email: '[email protected]', name: 'Tom', seq: 16}, 50: {email: '[email protected]', name: 'Boy', seq: 50}}
obj['16'] = {email: '', name: 'Tom', seq: 16}
and also it might have more than two objects, so also cannot just hard coding like
const obj = {16: {email: '[email protected]', name: 'Tom', seq: 16}, 50: {email: '[email protected]', name: 'Boy', seq: 50}}
obj['16'] = {email: '', name: 'Tom', seq: 16}
obj['50'] = {email: '', name: 'Tom', seq: 50}
could anyone help me? 🙁
2
Answers
If you want to convert and manipulate your data as an array, I suggest that you use Object.entries() and map(). Then you can reset the email values through forEach.