我正在使用C=0抽样计划创建一个QA抽样计算器。每当我输入任何数字并尝试它时,提供给我的结果与不同范围的结果相对应。
const sample = parseFloat(this.sampleSize)
const lot = parseFloat(this.lotSize)
if (aqlSelector.value == 0.010) {
if (this.sampleSize > 0 || this.sampleSize <= 1200) {
lotQty.innerText = 'All'
console.log(sample)
console.log(lot)
} else if (this.sampleSize >= 1201) {
lotQty.innerText = '1250'
}
}
尝试不同方法后的代码结果
整个项目的代码:https://codepen.io/cesar-higashi/pen/LYbPwaJ
使用了错误的逻辑运算符if (this.sampleSize > 0 || this.sampleSize <= 1200)
应该是if (this.sampleSize > 0 && this.sampleSize <= 1200)
对于您的||
(or),它首先返回大于0的每个值
解决了!
结果是,代码中的某个部分为长数字添加了逗号(',')以使它们更容易阅读,这反过来又使它们成为NaN。
一旦项目结束,我会更新codependency。对于所有花时间的人,非常感谢。