var strArray = [ "q", "w", "w", "e", "i", "u", "r", "q"];
var alreadySeen = [];
strArray.forEach(function(str) {
if (alreadySeen[str])
alert(str);
else
alreadySeen[str] = true;
});
I added another duplicate in there from your original just to show it would find a non-consecutive duplicate.
Updated version with arrow function:
const strArray = [ "q", "w", "w", "e", "i", "u", "r", "q"];
const alreadySeen = [];
strArray.forEach(str => alreadySeen[str] ? alert(str) : alreadySeen[str] = true);