输出1-50之间被5整除的数字,找到则停止

for (var i = 1; i <= 50; i++) {
    if(i % 5 == 0){
        
    console.log(i);
    break;

} 
   }

2023-06-26T13:50:44.png

停止内部循环

for (var i = 1; i <= 4; i++) {

    for(var j = 1; j <= 4; j++) {

        console.log(i,j);

        if(j >= 2){
            
            break;
        }
    }
}

2023-06-26T14:02:01.png

停止外部循环

 waiceng :   for (var i = 1; i <= 4; i++) {

        for(var j = 1; j <= 4; j++) {

            console.log(i,j);

            if(j >= 2){

                break waiceng;
            }
        }
    }

2023-06-26T14:03:57.png