Skip to content

JavaScript array some method | check element in the array

  • by

JavaScript array some Method is check condition is true or not. It executes the function once for each element present in the array and returns a Boolean value.

Simply we use some() method to Check If at Least one Array Element Passes a Test.

Note: It doesn’t change the original array and will not execute the function for array elements without values.

Example of JavaScript array some method

Let’s see simple HTML example code of it:-

The example will check if any mark value is greater or equal to 30.

<!DOCTYPE html>
<html>
<head>
    <script type="text/javascript">

        var marks = [13, 80, 68, 20];

        function checkMarks(marks) {
          return marks >= 30;
      }

      alert(marks.some(checkMarks))

  </script>
</head>
<body>

</body>
</html>

Output:

JavaScript array some method

Do comment if you have another example on this topic. You can also ask doubts.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Discover more from Tutorial

Subscribe now to keep reading and get access to the full archive.

Continue reading