How to check whether at least one element in array is odd in JavaScript

1 Answer

0 votes
const array = [2, 4, 5, 6, 8];

const odd = (element) => element % 2 !== 0;

console.log(array.some(odd));

  
    
    
/*
run:
    
true
    
*/

 



answered Dec 3, 2020 by avibootz
...