Skip to content

Instantly share code, notes, and snippets.

@federicobucchi
Created October 16, 2014 17:15
Show Gist options
  • Save federicobucchi/260e4de3d3bc2a96abdf to your computer and use it in GitHub Desktop.
Save federicobucchi/260e4de3d3bc2a96abdf to your computer and use it in GitHub Desktop.
function firstNotRepeatedChar(str) {
var arr = str.split('');
var result = '';
var count = 0;
for (var i = 0; i < arr.length; i++) {
count = 0;
for (var y = 0; y < arr.length; y++) {
if (arr[i] == arr[y]) {
count +=1;
}
}
if (count < 2) {
result = arr[i];
break;
}
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment