Hi, is there a way to exclude an item from a json list where i pick up a random one?
Example i want to exclude the items there the attribute special=1. Is there a way?
1 Like
Hi @ayrin,
That’s quite easy if you are using ES6 Javascript:
// --- items will contain only objects that don't have a special attribute or its value is !== 1
const items = myList.filter( (o) => {
return o.special !== 1;
});
If you are targeting ES5 JS you can rewrite it using a regular loop and an if statement to populate your array.
1 Like
thx @Leonidas i will use you es6 example, today i will be slow, my right shoulder is totally out of service
2 Likes
@Leonidas it works perfectly, now special items will be available just by solving quests thanks
1 Like