0
Q:

array.filter in javascript not working in w3schools


 var ages = [32, 33, 16, 40];

function checkAdult(age) {
  return age >= 18;
}

 
function myFunction() {
  document.getElementById("demo").innerHTML = ages.filter(checkAdult);
} 
0
var ages1 = [32, 33, 16, 40];

var newages1 = ages1.filter((curElm)=>{
    return curElm>18
})
console.log(newages1);
0

New to Communities?

Join the community