javascript check if any value in array is true
let boolArray1 = [true, false, false]
let boolArray2 = [false, false, false]
boolArray1.some(x => x); // true
boolArray2.some(x => x); // false
// Example of using a function to evaluate array
let numberArray = [1, 2, 3, 4, 5];
let oddNumbers = [1, 3, 5, 7, 9];
// checks whether an element is even
const even = (element) => element % 2 === 0;
numberArray.some(even); // true
oddNumbers.some(even); // false
Also in JavaScript:
- loop javascript
- global site tag (gtag.js) - google analytics gatsby
- hex string to int javascript
- javascript date countdown
- codemirror get value
- vuejs send required props to dynamic component
- check if object is present in array javascript
- js create element with class
- js convert object to string
- jquery get
- hide status bar react native
- import fs node js
- js how to add two arrays together
- jquery on scroll down
- how to use reduce javascript
- npm
- angular http get status code
- javascript redirect function
- js change contenteditable value
- material ui align icon with text
- array con doble javascript
- element.classname javascript
- javascript repeat each second
- jquery for each tr in td