Понимание функций JavaScript более высокого порядка
function evenNumberFilter(number) {
return number %2 == 0
}
function oddNumberFilter(number) {
return !evenNumberFilter(number)
}
function evenNumberBeforeTen() {
const result = []
for(number=0; number<10; number++) {
if (evenNumberFilter(number)) {
result.push(number)
}
}
return result
}
function oddNumberBeforeTen() {
const result = []
for(number=0; number<10; number++) {
if (oddNumberFilter(number)) {
result.push(number)
}
}
return result
}
evenNumberBeforeTen(); //[0,2,4,6,8]
oddNumberBeforeTen(); //[1,3,5,7,9]
SAMER SAEID