Trying to find array have same values or not in typescript but not working. So, How to findout. If anyone knows please help to find the solution.
app.component.ts:
arr1 = ['1256','1256','1256'];
arr2 = ['1256','8259','1256'];
newArr=[];
checkVal(val){
val.forEach(x=>{
this.newArr.push(x);
});
if(this.newArr){
alert("All the values are same in the array")
}else{
alert("No Diffent values are there in this array")
}
}
checkValApply1(){
this.checkVal(this.arr1)
}
checkValApply2(){
this.checkVal(this.arr2)
}
Demo: https://stackblitz.com/edit/angular-ivy-9xyxxm?file=src%2Fapp%2Fapp.component.ts