Find repeating elements in a given array

The problem:

Write a program to show repeating elements in an array. Consider the time complexity when writing code.

Problem description

The array length can be any integer (N) and print the number as soon as you find a duplicate.

    const arr = [2, 7, 4, 7, 8, 3, 4];
    for(let i = 0; i < arr.length; i++){
        for(let j = 0; j <= i; j++) {
            if(arr[j] === arr[i] && j !== i){
                console.log(arr[i]);
                break;
            }
        }
    }