//find the first duplicate-----------------------------------
var s="172223237";
function firstDuplicate(s)
{
for(var i=0;i<s.length;i++)
{
for(var j=(i+1);j<s.length;j++)
{
if(s[i]===s[j])
{
return s[i];
}
}
}
}
console.log(firstDuplicate(s));
Comments
Post a Comment