简体   繁体   中英

Count Number of even elements in PureScript

We have given an array and we have to find the number of even elements in the array using recursive function in purescript. We have to use head function also

var arr = [4,5,7,8,14,45,76];
var countEvens = arr.filter(number => number % 2 == 0).length;
console.log(countEvens);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM