Saturday, July 14, 2018

hi

<div></div>
function filter2(array, callback){
  let newArr =[];
 
  for(let i=0;i<array.length;i++){
    if(callback(array[i],i,array)){
      newArr.push(array[i]);
    }
  }
  return newArr;
}
 
callback(value){
  return value>2
 
}
 
filter2([1,2,3])
 
var arr = [1,2,3];
arr.filter2((value)=>{
  return value>2
})
 

No comments:

Post a Comment

Day 13

(2) so is that possible to build it from scratch? (3) is that mean it’s better to do that by service? how about if i want to find a API? ...