Check for repeated characters in a string Javascript
问题 I was wondering if there is a way to check for repeated characters in a string without using double loop. Can this be done with recursion? An example of the code using double loop (return true or false based on if there are repeated characters in a string): var charRepeats = function(str) { for(var i = 0; i <= str.length; i++) { for(var j = i+1; j <= str.length; j++) { if(str[j] == str[i]) { return false; } } } return true; } Many thanks in advance! 回答1: (A recursive solution can be found at