switch

const x = 10;
const color = x > 10 ? 'red' : 'blue';

switch (color) {
    case 'red':
        console.log('The color is red');
        break;
    case 'blue':
        console.log('The color is blue');
        break;
    default:
        console.log('The color is neither red nor blue');
        break;
}
console.log(color);

  

posted @ 2025-07-11 16:39  华腾智算  阅读(7)  评论(0)    收藏  举报
https://damo.alibaba.com/ https://tianchi.aliyun.com/course?spm=5176.21206777.J_3941670930.5.87dc17c9BZNvLL