Guest User

Untitled

a guest
Nov 19th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. function findFirstRepeatedChar(s){
  2. for(let i=0; i<s.length; i++){
  3. if(s[i] == s[i+1]){
  4. return s[i];
  5. }else if(s.indexOf(s[i], i+1) != -1){
  6. return s[i];
  7. }
  8. }
  9. return false;
  10. }
  11. console.log(findFirstRepeatedChar("ABCCBD"));
  12. //console.log(findFirstRepeatedChar("ABCDB"));
  13. //console.log(findFirstRepeatedChar("ABCDE"));
Add Comment
Please, Sign In to add comment