0
Take a sample array of objects n number length. on every 3rd and 5th array push new key value "insert:10"
Eg: input: [{id:1},{id:2}.{id:3}] output: [{id:1},{id:2},{id:3,insert:10}]
7 Réponses
+ 1
Just want like this
output: [{id:1},{id:2},{id:3,insert:10}, id:4},{id:5,insert:10}, {id:1},{id:2},{id:3,insert:10}, id:4},{id:5,insert:10}]
+ 2
anything you have tried so far ?
+ 2
Padala Bala Sirisha what do you mean by 3rd and 5th ? Is it like 3,5,7,9 and so on or something else ?
+ 1
Padala Bala Sirisha
let a=[{id:1},{id:2},{id:3}]
a.map((item)=>{
if(item.id === 3 || item.id == 5){
item.insert=10
}
})
+ 1
Thank you
0
No
0
This is not getting output