let's say I have an array
const defaultList = [
{
"name":"John",
"last_name":"doe"
},
{
"name":"Alice",
"last_name":"Smith"
}
]
I want using for loop to add new value online, so in the end it will look like this
const defaultList = [
{
"name":"John",
"last_name":"doe",
"online":"yes"
},
{
"name":"Alice",
"last_name":"Smith",
"online":"no"
}
]
I am using React Hooks and array is defined in this way, where later I fill it with data above:
const [defaultList, setDefaultList] = useState([]);
I would appreciate any idea how to do it?
Thank You!