I have array of object like this
let arr = [
{
"james-0": {
"value": "",
"error": false
},
"john-0": {
"value": "",
"error": false
},
"jordan-0": {
"value": "",
"error": false
}
}
]
I want to alter error to true if the value is not false / empty string.
I tried this but it deosn't seem to work, I can't hardcode james-${i}
arr = arr.map((o,i) => {
let prop = o[`james-${i}`]
if(!prop.value) prop.error = true
console.log(prop)
return {
...o,
[`james-${i}`]: prop
}
})