How to create a new array from all elements in array that pass a condition in JavaScript

1 Answer

0 votes
const array = [1, 5, 7, 2, 1, 12, 6, 4];

const result = array.filter(n => n > 5);

console.log(result);


  
    
    
/*
run:
    
[7, 12, 6]
    
*/

 



answered Nov 30, 2020 by avibootz
...