老师请检查代码,谢谢

来源:2-7 编程练习

慕的地7233660

2022-06-07 23:19:15

 const arr=['i','m','o','o','e']
        //for...of循环数组  entries()方法 索引+值的可遍历对象
        for([index,value] of arr.entries()){
           // console.log(index,value)
           //判断值为'o'时的情况
            if(value==='o'){
                //将值变为大写
              arr[index]=value.toLocaleUpperCase();
              //跳出循环,不然第二个'o'也会变为大写
              break;
            }
        }
        console.log(arr)


写回答

1回答

好帮手慕星星

2022-06-08

同学你好,代码实现效果很棒。继续加油,祝学习愉快!

0

0 学习 · 17877 问题

查看课程