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');