If you were to find the first non-repeating alphabet in the string, is there any better way to do it?

var str = "aaabbcddeff"

str = str.split("").sort();

for(i=0;i<str.length;i++){
  if(str[i] != str[i-1] && str[i] != str[i+1] ){
  console.log(str[i]);
  break;
  }
}

“c” ofcourse!!..

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

markdown_Forums