跪求!这几个function重复性过高,怎么优化会更好?

html:
{{aaa}}:
{{bbb}}:
{{ccc}}:
ts:
oCode_test1(oCode){
if(oCode=='aa'||oCode=='aa1st'||oCode=='aah2'||
oCode=='aaq1'||oCode=='aaq3'||oCode=='aaq4'){
returntrue
}
returnfalse
}
oCode_test2(oCode){
if(oCode=='qq'||oCode=='qq1st'||oCode=='qqh2'||
oCode=='qqq1'||oCode=='qqq3'||oCode=='qqq4'){
returntrue
}
returnfalse
}
oCode_test3(oCode){
if(oCode=='ww'||oCode=='ww1st'||oCode=='wwh2'||
oCode=='wwq1'||oCode=='wwq3'||oCode=='wwq4'){
returntrue
}
returnfalse
}
ts的部分,感觉重复性过高,该怎么优化,3个function有办法合并成一个吗?
肥皂起泡泡
浏览 315回答 2
2回答

FFIVE

publicreadonlytestCaseOne=['aa','aa1st','aah2','aaq1','aaq3','aaq4'];publicoCode_test(oCode,testCase){returntestCase.includes(oCode);}{{aaa}}:
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript