function getEvenCount(list) {
return list.filter(item =>
(typeof item === 'number') && (item % 2 === 0)
).length;
}
function getOddCount(list) {
return list.filter(item =>
(typeof item === 'number') && (item % 2 !== 0)
).length;
}
document.write(
'getEvenCount([2,4,8,7]) ... ' +
getEvenCount([2,4,8,7]) +
'</br>'
)
document.write(
'getEvenCount([1,9,66,"banana"]) ... ' +
getEvenCount([1,9,66,"banana"]) +
'</br>'
)
document.write(
'getOddCount([2,4,8,7]) ... ' +
getOddCount([2,4,8,7]) +
'</br>'
)
document.write(
'getOddCount([1,9,66,"banana"]) ... ' +
getOddCount([1,9,66,"banana"]) +
'</br>'
)
console.log(
'getEvenCount([2,4,8,7]) ... ',
getEvenCount([2,4,8,7])
);
console.log(
'getEvenCount([1,9,66,"banana"]) ...',
getEvenCount([1,9,66,"banana"])
);
console.log(
'getOddCount([2,4,8,7]) ...',
getOddCount([2,4,8,7])
);
console.log(
'getOddCount([1,9,66,"banana"]) ...',
getOddCount([1,9,66,"banana"])
);