Имеется массив в json
[{
"id":1,
"users":{
"newId":{"bet":0},
"newId2":{"bet":1},
"newId3":{"bet":1}
}
}]
Как мне найти юзеров со ставкой 1 и добавить им +10 еще?
users — объект объектов, а не массив объектов.json. const $json = '[{"id":1,"users":{"newId":{"bet":0},"newId2":{"bet":1},"newId3":{"bet":1}}}]';
let js_parse = JSON.parse($json);
for(index in js_parse) {
if(!!js_parse[index].users.newId.bet){
js_parse[index].users.newId.bet += 10;
}
if(!!js_parse[index].users.newId2.bet){
js_parse[index].users.newId2.bet += 10;
}
if(!!js_parse[index].users.newId3.bet){
js_parse[index].users.newId3.bet += 10;
}
}
console.log(js_parse);
Продвижение своими сайтами как стратегия роста и независимости