【发布时间】:2014-09-27 05:56:55
【问题描述】:
getProductType = function (product) {
var productType = '';
if (product.standardVariable) {
productType += 'Standard Variable, ';
}
if (product.basic) {
productType += 'Basic, ';
}
if (product.intro) {
productType += 'Intro, ';
}
if (product.fixed) {
productType += 'Fixed, ';
}
if (product.equity) {
productType += 'Equity';
} else {
alert(productType);
productType.substring(0, productType.length - 2);
alert(productType);
}
return productType;
};
我的测试用例是 product.fixed = true,其他都是 false。
为什么我的两个警报都打印出“已修复”?为什么子字符串不起作用?
【问题讨论】:
标签: javascript string substring