let x = 55 let level = $branches.ifElse((ifElse) => { ifElse.add(() => { return x >= 90 && x < 100 }, () => { return "优秀" }) ifElse.add(() => { return x >= 80 && x < 90 }, () => { return "好" }) ifElse.add(() => { return x >= 70 && x < 80 }, () => { return "良" }) ifElse.add(() => { return x >= 60 && x < 70 }, () => { return "及格" }) ifElse.addDefault(() => { return "不及格" }) }) $console.log(level) level = $branches.switchCase(85, (switchCase) => { switchCase.add((it) => { return it >= 90 && it < 100 }, () => { return "优秀" }) switchCase.add((it) => { return it >= 80 && it < 90 }, () => { return "好" }) switchCase.add((it) => { return it >= 70 && it < 80 }, () => { return "良" }) switchCase.add((it) => { return it >= 60 && it < 70 }, () => { return "及格" }) switchCase.addDefault(() => { return "不及格" }) }) $console.log(level)