So here is my code, it is in NodeJS and not javascript :
while (otn !== -1) {
var li= inventory.length - 1;
while (li !== -1){
li = li- 1;
if (inventory[li].market_name === orderitemname[otn]){
console.log("Add item to trade " + orderitemname[otn]);
offer.addMyItem(inventory[li]);
console.log(inventory[li])
delete inventory[li];
//Close everything
So everything is working fine, except delete inventory[li]
, what it does is it's deleting the value from the json, but when the while loop runs again, the program tries to read the value from the same and crashes, so is there a way we could like completely delete it(The following bunch of code) and then not even have it listed ? Btw here is my JSON :
CEconItem {
appid: 730,
contextid: '2',
assetid: '13799167798',
classid: '506854340',
instanceid: '188530139',
amount: 1,
pos: 1,
id: '13799167798',
background_color: '',
icon_url: blah,
icon_url_large: blah,
descriptions: [ [Object], [Object], [Object], [Object], [Object], [Object] ],
tradable: true,
actions: [ [Object] ],
name: 'P90 | Module',
name_color: 'D2D2D2',
type: 'Mil-Spec Grade SMG',
market_name: 'P90 | Module (Factory New)',
market_hash_name: 'P90 | Module (Factory New)',
market_actions: [ [Object] ],
commodity: false,
market_tradable_restriction: 7,
marketable: true,
tags: [ [Object], [Object], [Object], [Object], [Object], [Object] ],
is_currency: false,
market_marketable_restriction: 0,
fraudwarnings: [] },
And a lot of these...
Any help would be greatly appreciated :) Thanks!
PS: I'm a complete noobie, if I'm missing something as simple as cake, please don't roast me :)