What is the usage of some() method in JavaScript?

HTMLJavascriptProgramming Scripts

To add a test for the elements of the array, such as checking voter age, etc, then use the JavaScript some() method.


You can try to run the following code to learn how to work with some() method in JavaScript.

<!DOCTYPE html>
         var voter_ages = [17, 15, 19, 16, 20];
            function voterAge(myAge) {
               return myAge >= 18;
            document.write("Minimum Voter Age in the list: "+voter_ages.some(voterAge));
Updated on 23-May-2020 11:04:35