switch语句的case省略了break语句,则会执行以下case语句,直到遇到break 。如果您有多个具有相同输出的输入,则可以在switch语句中表示它们,如下所示: switch(val){1,2和3的情况都会产生相同的结果。
情况1:
案例2:
案例3:
result =“1,2或3”;
打破;
案例4:
result =“4 alone”;
}
answer : 1-3 - “低” 4-6 - “中” 7-9 - “高” 注 case语句。 sequentialSizes(1)应返回“Low”
testString: 'assert(sequentialSizes(1) === "Low", "sequentialSizes(1) should return "Low"");'
- text: sequentialSizes(2)应该返回“Low”
testString: 'assert(sequentialSizes(2) === "Low", "sequentialSizes(2) should return "Low"");'
- text: sequentialSizes(3)应返回“Low”
testString: 'assert(sequentialSizes(3) === "Low", "sequentialSizes(3) should return "Low"");'
- text: sequentialSizes(4)应返回“Mid”
testString: 'assert(sequentialSizes(4) === "Mid", "sequentialSizes(4) should return "Mid"");'
- text: sequentialSizes(5)应返回“Mid”
testString: 'assert(sequentialSizes(5) === "Mid", "sequentialSizes(5) should return "Mid"");'
- text: sequentialSizes(6)应返回“Mid”
testString: 'assert(sequentialSizes(6) === "Mid", "sequentialSizes(6) should return "Mid"");'
- text: sequentialSizes(7)应该返回“High”
testString: 'assert(sequentialSizes(7) === "High", "sequentialSizes(7) should return "High"");'
- text: sequentialSizes(8)应该返回“High”
testString: 'assert(sequentialSizes(8) === "High", "sequentialSizes(8) should return "High"");'
- text: sequentialSizes(9)应该返回“High”
testString: 'assert(sequentialSizes(9) === "High", "sequentialSizes(9) should return "High"");'
- text: 您不应该使用任何if或else语句
testString: 'assert(!/else/g.test(code) || !/if/g.test(code), "You should not use any if or else statements");'
- text: 你应该有九个case陈述
testString: 'assert(code.match(/case/g).length === 9, "You should have nine case statements");'
```