请使用三元表达式简化以下代码:{[ntgls, ytgls, stgls].filter(item => item == '(比劫)').length >= 2 ? xg.bjtg : null} {[ncdzls1, ncdzls2, ncdzls3, ycdzls1, ycdzls2, ycdzls3, rcdzls1, rcdzls2, rcdzls3, scdzls1, scdzls2, scdzls3].filter(item => item == '(比劫)').length >= 3 ? xg.bjdz : null} {[ncdzls1, ncdzls2, ncdzls3, ycdzls1, ycdzls2, ycdzls3, rcdzls1, rcdzls2, rcdzls3, scdzls1, scdzls2, scdzls3].filter(item => item == '(正官)').length >= 3 ? xg.zg : null} {[ncdzls1, ncdzls2, ncdzls3, ycdzls1, ycdzls2, ycdzls3, rcdzls1, rcdzls2, rcdzls3, scdzls1, scdzls2, scdzls3].filter(item => item == '(七杀)').length >= 3 ? xg.qs : null} {[ncdzls1, ncdzls2, ncdzls3, ycdzls1, ycdzls2, ycdzls3, rcdzls1, rcdzls2, rcdzls3, scdzls1, scdzls2, scdzls3].filter(item => item == '(正财)').length >= 3 ? xg.zc :null} {[ncdzls1, ncdzls2, ncdzls3, ycdzls1, ycdzls2, ycdzls3, rcdzls1, rcdzls2, rcdzls3, scdzls1, scdzls2, scdzls3].filter(item => item == '(偏财)').length >= 3 ? xg.zc : null} {[ncdzls1, ncdzls2, ncdzls3, ycdzls1, ycdzls2, ycdzls3, rcdzls1, rcdzls2, rcdzls3, scdzls1, scdzls2, scdzls3].filter(item => item == '(正印)').length >= 3 ? xg.zy : null} {[ncdzls1, ncdzls2, ncdzls3, ycdzls1, ycdzls2, ycdzls3, rcdzls1, rcdzls2, rcdzls3, scdzls1, scdzls2, scdzls3].filter(item => item == '(偏印)').length >= 3 ? xg.py : null} {[ncdzls1, ncdzls2, ncdzls3, ycdzls1, ycdzls2, ycdzls3, rcdzls1, rcdzls2, rcdzls3, scdzls1, scdzls2, scdzls3].filter(item => item == '(伤官)').length >= 3 ? xg.sg : null} {[ncdzls1, ncdzls2, ncdzls3, ycdzls1, ycdzls2, ycdzls3, rcdzls1, rcdzls2, rcdzls3, scdzls1, scdzls2, scdzls3].filter(item => item == '(食神)').length >= 3 ? xg.ss : null}
时间: 2024-03-13 22:45:33 浏览: 54
```
const arr = [ncdzls1, ncdzls2, ncdzls3, ycdzls1, ycdzls2, ycdzls3, rcdzls1, rcdzls2, rcdzls3, scdzls1, scdzls2, scdzls3];
const bjCount = arr.filter(item => item == '(比劫)').length;
const zgCount = arr.filter(item => item == '(正官)').length;
const qsCount = arr.filter(item => item == '(七杀)').length;
const zcCount = arr.filter(item => item == '(正财)' || item == '(偏财)').length;
const zyCount = arr.filter(item => item == '(正印)').length;
const pyCount = arr.filter(item => item == '(偏印)').length;
const sgCount = arr.filter(item => item == '(伤官)').length;
const ssCount = arr.filter(item => item == '(食神)').length;
bjCount >= 2 ? xg.bjtg : null;
bjCount >= 3 ? xg.bjdz : null;
zgCount >= 3 ? xg.zg : null;
qsCount >= 3 ? xg.qs : null;
zcCount >= 3 ? xg.zc : null;
zyCount >= 3 ? xg.zy : null;
pyCount >= 3 ? xg.py : null;
sgCount >= 3 ? xg.sg : null;
ssCount >= 3 ? xg.ss : null;
```
阅读全文