How to check if array contains a duplicate string , i have validateArray = ['sa','sa','yu'] i have used the following function from SO but same not working for me.
checkDuplicate = function (reportRecipients) {
if (reportRecipients.length > 1) {
var recipientsArray = reportRecipients.toString().split(',');
for (a in recipientsArray) {
if(reportRecipients.indexOf(a) != reportRecipients.lastIndexOf(a)){
return true;
break;
}
}
}
return false;
}