let arr = [1,2,1,1,3,3,3,4,5];


console.log(arrayIsRepet(arr));
function arrayIsRepet(arr){//判断数组中存在重复元素
  let b = [];
  let c = [];
  arr.forEach(item => {
    if(c.indexOf(item) == -1){
      c.push(item);
    }else{
      b.push(item);
    }
  });
  if(b.length > 0){
    return true;
  }else{
    return false;
  }
}

 

 

 

相关文章:

  • 2021-10-25
  • 2022-02-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-27
猜你喜欢
  • 2022-12-23
  • 2021-08-10
  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
  • 2021-10-31
  • 2021-11-07
相关资源
相似解决方案