Check If Every Element Of An Array Pass A Test

[Solved] Check If Every Element Of An Array Pass A Test | Solidity - Code Explorer | yomemimo.com
Question : Check if any of the elements in an array pass a test

Answered by : successful-seal-2wt1mf2yfsdx

const people = [ {name: 'John', age: 23}, {name: 'Andrew', age: 3}, {name: 'Peter', age: 8}, {name: 'Hanna', age: 14}, {name: 'Adam', age: 37}];
const anyAdult = people.some(person => person.age >= 18);
console.log(anyAdult); // true

Source : https://stackoverflow.com/questions/16626735/how-to-loop-through-an-array-containing-objects-and-access-their-properties | Last Update : Mon, 18 May 20

Question : check if every element of an array pass a test

Answered by :

let numbers = [1, 3, 5];
let result = numbers.every( e => e > 0);
console.log(result);
Code language: JavaScript (javascript)

Source : https://www.javascripttutorial.net/javascript-every/ | Last Update : Thu, 30 Dec 21

Answers related to check if every element of an array pass a test

Code Explorer Popular Question For Solidity