我很好奇是否可以用lodash函数替换这个for循环?你会如何实现它?为了性能原因或可读性,为什么你(或不愿意)用lodash函数替换for循环?
for (var i = 0; (i + 3) < username.length + 1; i++) {
if (_.includes(password, username.substring(i, i + 3))) {
warning = "Passwords cannot contain 3 or more " +
"consecutive characters from user name";
alerting.addDanger(warning);
return false;
}
}