if/else
语句可以链接在一起以用于复杂的逻辑。这是多个链式if
/ else if
语句的伪代码 : if( condition1 ){
语句1
} else if( condition2 ){
语句2
} else if( condition3 ){
声明3
。 。 。
} else {
statementN
}
if
/ else if
语句以满足以下条件: num < 5
- return“Tiny” num < 10
- 返回“Small” num < 15
- 返回“中” num < 20
- 返回“Large” num >= 20
- 返回“巨大” else
语句
testString: 'assert(code.match(/else/g).length > 3, "You should have at least four else
statements");'
- text: 你应该至少有四个if
语句
testString: 'assert(code.match(/if/g).length > 3, "You should have at least four if
statements");'
- text: 你应该至少有一个return
语句
testString: 'assert(code.match(/return/g).length >= 1, "You should have at least one return
statement");'
- text: testSize(0)
应该返回“Tiny”
testString: 'assert(testSize(0) === "Tiny", "testSize(0)
should return "Tiny"");'
- text: testSize(4)
应该返回“Tiny”
testString: 'assert(testSize(4) === "Tiny", "testSize(4)
should return "Tiny"");'
- text: testSize(5)
应返回“Small”
testString: 'assert(testSize(5) === "Small", "testSize(5)
should return "Small"");'
- text: testSize(8)
应该返回“Small”
testString: 'assert(testSize(8) === "Small", "testSize(8)
should return "Small"");'
- text: testSize(10)
应该返回“Medium”
testString: 'assert(testSize(10) === "Medium", "testSize(10)
should return "Medium"");'
- text: testSize(14)
应返回“Medium”
testString: 'assert(testSize(14) === "Medium", "testSize(14)
should return "Medium"");'
- text: testSize(15)
应该返回“Large”
testString: 'assert(testSize(15) === "Large", "testSize(15)
should return "Large"");'
- text: testSize(17)
应该返回“Large”
testString: 'assert(testSize(17) === "Large", "testSize(17)
should return "Large"");'
- text: testSize(20)
应该返回“巨大”
testString: 'assert(testSize(20) === "Huge", "testSize(20)
should return "Huge"");'
- text: testSize(25)
应该返回“巨大”
testString: 'assert(testSize(25) === "Huge", "testSize(25)
should return "Huge"");'
```