how to use filter in array in Javascript

In this case we will be return a value from array and that value will be above 18 and below 60.

function Solution(n){
  var newB = [];
  n.filter((item) => {
    if(item > 17 && item < 61){
      newB.push(item);
      }
  })
  return newB.toString();
}

Leave a Reply

Your email address will not be published. Required fields are marked *