DEV Community

Mehul Lakhanpal
Mehul Lakhanpal

Posted on • Originally published at codedrops.tech

Array.every()

Check if all the elements in the array are greater than 0 using .every().

const arr = [1, 2, -1, 4, -5];

const allGreaterThanZero = arr.every(number => number > 0);
console.log(allGreaterThanZero); // false
Enter fullscreen mode Exit fullscreen mode

Thanks for reading 💙

Follow @codedrops.tech for daily posts.

InstagramTwitterFacebook

Micro-Learning ● Web Development ● Javascript ● MERN stack ● Javascript

codedrops.tech

Top comments (3)

Collapse
 
zdev1official profile image
ZDev1Official

Good, thanks

Collapse
 
dcsan profile image
dc

underrated API :D

Collapse
 
ml318097 profile image
Mehul Lakhanpal

Haha.. But it might be of use someday 😅