Discuss / JavaScript / Answer

Answer

Topic source

NotFatCat

#1 Created at ... [Delete] [Delete and Lock User]
 return arr.filter(function(n){
        if(n===1) return false;
        for(let i = 2;i<=Math.sqrt(n);i++){
             if(n%i===0) return false; 
          }
        return true;
     });

  • 1

Reply