OMG I keep forgetting about <<capture>>
being a thing…
I’ve tried the code they provided + edits for <<capture>>
,
<<for _i = 0; _i < $Inventory.length; _i++>>
<<capture _i>>
<span @id= "'Item-' + _i ">$Inventory[_i].InventoryName
<<link "Toss Item">><<run $Inventory.deleteAt(_i)>><<remove`"#Item-"+ _i`>><</link>></span>
<</capture>>
<</for>>
and it works: removed the element + the correct item in the array.