// Write a code that given an input string, returns the first non - repeating character
//Example input: "godisgood"
//Output: "i"
// Write a code that given an input string, returns the first non - repeating character
//Example input: "godisgood"
//Output: "i"
function firstNotRepeated(text){
for (var i= 0; i< text.length; i++){
var letra = text.charAt(i);
var indice = text.indexOf(letra,0);
var indice2 = text.indexOf(letra, i+1);
if (indice == i && text.indexOf(letra, i + 1) == -1){
console.log(letra);
return null;
}
}
}
firstNotRepeated("igsxodisgoodxz")
Created
January 9, 2020 00:07
-
-
Save federicojd/dcf4e67d5af5aa4d89e75b4e9cb2bc63 to your computer and use it in GitHub Desktop.
Write a code that given an input string, returns the first non - repeating character
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment