I have an array of objects with arrays of consecutive integers, and an integer value:
const worlds = [
{levelnumbers: [0,1,2,3,4,5]},
{levelnumbers: [6,7,8,9,10]},
{levelnumbers: [11,12,13,14]}];
const reachedLevel = 9;
I want to determine if reachedLevel or a value lower than that is contained in each world object and set a locked value on each object.
I have tried this:
worlds.forEach(world => {
world.locked = !world.levelnumbers.includes(reachedLevel);
}
);
But is "locks" all worlds but the one containing the actual reached level. I want worlds[0] to have locked set to false even though levelReached is eg. 10.