const numbers = [1, 2, 3, 2, 4, 5, 5, 6];
let isDuplicate = false;
// Outer for loop
for (let i = 0; i < numbers.length; i++) {
// Inner for loop
for (let j = 0; j < numbers.length; j++) {
// Skip self comparison
if (i !== j) {
// Check for duplicate
if (numbers[i] === numbers[j]) {
isDuplicate = true;
// Terminate inner loop
break;
}
}
// Terminate outer loop
if (isDuplicate) {
break;
}
}
}
if (!isDuplicate) {
console.log(`Array doesn't contain duplicates.`);
} else {
console.log(`Array contains duplicates.`);
}
// Output: Array contains duplicates.