DEV Community

Cover image for some() in javascript
Raisan JMR
Raisan JMR

Posted on

some() in javascript

what is some() method in javascript with help of 2 example

EXAMPLE 1
we need to check if an array contain admin role, then only we need to give access to some resources in our application

simple stupid way is to use some() method in javascript

EXAMPLE 2

Here we have an array that has students' marks out of 20. and pass mark is 9, We need to check if all students have passed or not.if at least one student fails some() method returns false

EXAMPLE 3

consider we have an array of objects representing food items, and you want to check if at least one food item belong to a specific category such as 'Fruit'


❤️have a nice day❤️

Top comments (0)