Posisi karakter pertama yang tidak berulang dalam string

// First non repeating character position in a string

function first_non_repeating_letter(str) {
  for(var i = 0; i < str.length; i++) {
    if (str.indexOf(str[i]) === str.lastIndexOf(str[i])) {
      return i
    }
  }
  return null
}

console.log("First non repeating character position = " + 
    first_non_repeating_letter("abcdcba"));  //3
Mackerel