JS练习题之字符串一

file:///Users/july/Desktop/屏幕快照%202015-06-17%20下午9.29.42.png

 

  

        console.time('LEN2');
        function testSymbols(str) {
          var len = str.length-1;
          if (len < 3) {
            return false
          };
          if (str != null && len >= 3) {
            var arr = str.toLowerCase().split('');
            for (var i = 1; i < len - 1; i++) {
              if (arr[i] <= 'z' && arr[i] >= 'a') {
                if (arr[i - 1] == arr[i + 1] && arr[i - 1] == '+') continue;
                return false;
              }
            };
            return true
          };
        }
        testSymbols('+123+E+S+----+A++++S++----+D+e+');
        console.timeEnd('LEN2');

 

posted @ 2015-06-17 21:31  锦衣夜行4.2  阅读(378)  评论(0编辑  收藏  举报