Discuss / JavaScript / 第一题

第一题

Topic source

两仪藤乃

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

  • 1

Reply