|
if (randomNumbers.indexOf(nextNumber) === -1) { |
|
randomNumbers.push(nextNumber); |
|
} else { |
|
counter--; |
|
} |
This results in infinite loop if the array to be sorted, printed is set to more that 100 items. The solution is:
randomNumbers.push(nextNumber); // if (randomNumbers.indexOf(nextNumber) === -1) { // } else { // counter--; // }
comment out / or delete, the conditional if else clause to remove redundancy