请老师检查

来源:2-7 编程练习

慕斯2168053

2021-11-19 14:50:18

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <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) {
            //     arr.splice(2, 1, value.toUpperCase());
            // }

            //第二种方法
            if (value == 'o') {
                arr[index] = value.toUpperCase();
                break;
            }
        }
        console.log(arr);
    </script>
</body>

</html>


写回答

1回答

好帮手慕小李

2021-11-19

同学你好,第二种方法没有问题,棒棒的~

祝学习愉快~

0

0 学习 · 17877 问题

查看课程

相似问题