(Javascript) Determine if a numbervalue is contained or a number less than the numbervalue is contained in an array of objects

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.

84 thoughts on “(Javascript) Determine if a numbervalue is contained or a number less than the numbervalue is contained in an array of objects”

  1. 586116 87960Thank you for the sensible critique. Me and my neighbor were just preparing to do some research about this. We got a grab a book from our local library but I believe I learned more from this post. Im extremely glad to see such wonderful info being shared freely out there. 359517

    Reply
  2. I loved as much as you will receive carried out right
    here. The sketch is attractive, your authored subject matter stylish.

    nonetheless, you command get bought an nervousness over that you wish be delivering
    the following. unwell unquestionably come further formerly again as exactly the same nearly a
    lot often inside case you shield this hike.

    Reply
  3. Hey there! I’ve been reading your site for some time
    now and finally got the bravery to go ahead and give you a shout out from Porter Texas!
    Just wanted to tell you keep up the excellent work!

    Reply
  4. Hey would you mind letting me know which hosting company you’re working with?
    I’ve loaded your blog in 3 completely different web browsers
    and I must say this blog loads a lot faster then most.
    Can you suggest a good web hosting provider at a fair
    price? Many thanks, I appreciate it!

    Reply
  5. Have you ever considered about including a little bit more
    than just your articles? I mean, what you say is fundamental and everything.

    Nevertheless imagine if you added some great photos or videos to give your posts more, “pop”!
    Your content is excellent but with images and videos, this website could definitely be one of the best in its field.
    Amazing blog!

    Reply
  6. Good post. I learn something totally new and challenging on blogs I stumbleupon on a daily basis.
    It’s always interesting to read through articles from other writers and use something
    from other sites.

    Reply
  7. Attractive section of content. I just stumbled upon your web site and in accession capital
    to assert that I get in fact enjoyed account your blog posts.

    Any way I’ll be subscribing to your feeds and even I achievement you access
    consistently fast.

    Reply
  8. I am extremely inspired with your writing abilities and also with the structure for your blog.
    Is that this a paid subject matter or did you customize it yourself?

    Anyway stay up the nice quality writing, it’s rare to look a great weblog like this
    one nowadays..

    Reply
  9. When I initially commented I clicked the “Notify me when new comments are added” checkbox and now
    each time a comment is added I get four emails with the same comment.

    Is there any way you can remove me from that service?
    Many thanks!

    Reply
  10. Its like you read my mind! You seem to know a lot about this, like you
    wrote the book in it or something. I think that you can do with a few pics to
    drive the message home a little bit, but other than that, this is fantastic
    blog. An excellent read. I’ll certainly be back.

    Feel free to surf to my site … coupon

    Reply
  11. When I initially commented I appear to have clicked
    the -Notify me when new comments are added- checkbox and from now on every time a comment is added I receive four emails with the
    same comment. There has to be a way you are able to remove me from that service?

    Kudos!

    Reply
  12. With havin so much content do you ever run into any
    problems of plagorism or copyright infringement? My site has
    a lot of completely unique content I’ve either authored
    myself or outsourced but it appears a lot of it is popping it up all over the internet without my authorization. Do you know
    any ways to help stop content from being stolen? I’d genuinely
    appreciate it.

    Reply

Leave a Comment