我有以下代码,但在特定条件下无法跳出循环。
function isVoteTally(): boolean {
let count = false;
this.tab.committee.ratings.forEach((element) => {
const _fo = this.isEmptyOrNull(element.ratings.finalOutcome.finaloutlook);
const _foreign = this.isEmptyOrNull(element.ratings.finalOutcome.foreign);
const _local = this.isEmptyOrNull(element.ratings.finalOutcome.local);
const _tally =
element.ratings.finalOutcome.voteTally.maj +
element.ratings.finalOutcome.voteTally.dis;
if (_fo == false && _foreign == false && _local == false) {
if (_tally > 0) {
return (count = false); // ⭐
}
} else {
if (_tally < 0) {
return (count = false); // ⭐
}
}
});
return count;
}
在星标区域,我想破译代码并返回布尔值,但我无法做到。应该如何实现?