【发布时间】:2023-08-19 09:01:01
【问题描述】:
如何将此嵌套的if-else 语句转换为非嵌套的if-else if-else 语句?您可能需要添加一些布尔运算符以使其完全非嵌套:
if (ball > 0) {
if (cup > 0) {
console.log(“I have a ball and cup.”);
} else {
console.log(“I have a ball.”);
}
} else {
if (cup > 0) {
console.log(“I have a cup”);
} else {
console.log(“I have nothing”);
}
}
【问题讨论】:
标签: if-statement nested boolean