Get value from object in javascript
I have several objects as this structure:
Then I create a function to update the quantity of the item that matched
with search ID :
function setQuantityInCartByID(json, itemID, val){
for(var i in json){
console.log(json[i].ID);
if(json[i].ID == itemID){
json[i].QuantityInCart = val;
break;
}
}
return json;
}
Problem : console.log(json[i].ID);result is undefined.
No comments:
Post a Comment