check if all values in array are true javascript

Today, We want to share with you check if all values in array are true javascript.In this post we will show you check if all values in array are equal javascript, hear for How to check if array includes a value in JavaScript? we will give you demo and example for implement.In this post, we will learn about How to Check If an Element Exists in ReactJS? with an example.

Check if all values in array are true, then return a true

JavaScript Array every() Method

Example 1:

<!DOCTYPE html>

<p>Click the button to check if every products price in the array has a value of 18 or more.</p>

<button onclick="getLowPrice()">ClickIt</button>

<p id="example"></p>

var ages = [59, 36, 12, 45];

function testAllProduct(price) {
  return price >= 18;

function getLowPrice() {
  document.getElementById("example").innerHTML = ages.every(testAllProduct);


Check if all values in array are true, then return a true boolean statement (javascript)
Example 2:

let students_list = [false, true, true],
    students_b1_list = [true, true, true];

let checker = arr => arr.every(v => v === true);


Checking array elements using the for loop

Example 3:

let levels = [1, 3, 5];

let levels = [1, 3, 5];
let output = true;
for (let i = 0; i < levels.length; i++) {
    if (levels[i] <= 0) {
        output = false;

I hope you get an idea about Determining If All Array Elements Pass a Test.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Read Also:  Jquery check if value exists in Array Example

About Pakainfo

I am Jaydeep Gondaliya, a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Pakainfo →

Leave a Reply

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