老师,请检查
来源:2-7 编程练习
慕芸芸
2023-02-15 14:28:07
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
const arr = ["i", "m", "o", "o", "c"]
// 在此补充代码
for(let [index,value] of arr.entries()){
if(index==2&&value=='o'){
arr[index]=value.toUpperCase();
}
}
console.log(arr)
</script>
</body>
</html>
1回答
好帮手慕久久
2023-02-15
同学你好,代码是对的,可以优化一下。arr这个数组中的内容并不是固定的,即第一个o的索引可能并不是2,因此if判断可以调整一下:
祝学习愉快!