Check if all values in an array are true then return a true in JavaScript

In this short article, we will show you how to check if all values in an array are true then return a true boolean statement in JavaScript.

Let’s assume that we have the following array of booleans.

In the above code, the value of arr1 should be false as one item in the list is false while the value of arr2 should be true because all items are true.

We can use the every() method to get the desired output.

We can simply pass the Boolean as a callback to every() method.

That’s it for today.
Thank you for reading. Happy Coding..!! 🙂

If you found value in this article,
you can support us by buying me a coffee! ☕

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *