Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

First non repeating character position in a 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
Comment

PREVIOUS NEXT
Code Example
Javascript :: mongodb group by several fields 
Javascript :: syntax function 
Javascript :: react native linear gradient 
Javascript :: javascript in keyword 
Javascript :: conditional style react native 
Javascript :: get id of element javascript 
Javascript :: how to push array into array in angular 
Javascript :: how hide .html in url 
Javascript :: how to change package name in ios react native 
Javascript :: jquery dropdown select 
Javascript :: write json file c# 
Javascript :: set timeout 
Javascript :: dynamic route vue 
Javascript :: multipline and single line regex pattern 
Javascript :: javascript join list of string 
Javascript :: selected angular select 
Javascript :: push function in javascript 
Javascript :: difference between var and let 
Javascript :: vuex state from another module 
Javascript :: react native npm run start port 
Javascript :: eintegrity npm error 
Javascript :: emailjs react npm 
Javascript :: sort mongoose response 
Javascript :: find input by value attribute javascript 
Javascript :: email regex pattern input css 
Javascript :: array map destructuring 
Javascript :: react js date ago 
Javascript :: ERROR Invariant Violation: requireNativeComponent: "RNCViewPager" was not found in the UIManager. 
Javascript :: javascript fire keypress event 
Javascript :: remove duplicates from array of objects 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =