Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function findFirstRepeatedChar(s){
- for(let i=0; i<s.length; i++){
- if(s[i] == s[i+1]){
- return s[i];
- }else if(s.indexOf(s[i], i+1) != -1){
- return s[i];
- }
- }
- return false;
- }
- console.log(findFirstRepeatedChar("ABCCBD"));
- //console.log(findFirstRepeatedChar("ABCDB"));
- //console.log(findFirstRepeatedChar("ABCDE"));
Add Comment
Please, Sign In to add comment