hello i have creating a pragam that delete one array from another but. And it works fine i think but if i put 2 same value simultaneously, it remove only one value because of second argument of splice function. How can i check after deleting a element again if there any other number left my code is below.
const arr1 = [1, 2, 2, 3, 5, 2, 3, 7];
const arr2 = [2, 3];
let countArr = [];
for (let i = 0; i < arr2.length; i++) {
for (let j = 0; j <= arr1.length; j++) {
if (arr1[j] === arr2[i]) {
arr1.splice(j, 1);
}
}
}
console.log(arr1);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script src="demo.js"></script>
</body>
</html>