我想通过JS打印出“This is the first/second/third paragraph.”三行,然而出现问题

以下是我的代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>

    </style>
</head>
<body>
<div>

    <button>BUTTON</button>
</div>
<script>
    // 设想制作一个映射表
    /* +-------------+--------+
       | IndexNumber | Value  |
       +-------------+--------+
       | 0           | first  |
       | 1           | second |
       | 2           | third  |
       | 3           | fourth |
       | 4           | fifth  |
       +-------------+--------+ */

    for (let i = 0; i < 3; ++i) {
        switch (i) {
            case 0:
                i = 'first';
                break;
            case 1:
                i = 'second';
                break;
            case 2:
                i = 'third';
                break;
            case 3:
                i = 'fourth';
                break;
            case 4:
                i = 'fifth';
                break;
        }
        document.getElementsByTagName('div')[0].innerHTML += "This is the " + i + " paragraph.<br/>";
    }
</script>
</body>
</html>

以下是结果,只打印出了 “This is the first paragraph.”

img

求各位指点!

i被你的first覆盖了。后续做for循环判断被判断为退出循环了

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
 
    </style>
</head>
<body>
<div>
 
    <button>BUTTON</button>
</div>
<script>
    // 设想制作一个映射表
    /* +-------------+--------+
       | IndexNumber | Value  |
       +-------------+--------+
       | 0           | first  |
       | 1           | second |
       | 2           | third  |
       | 3           | fourth |
       | 4           | fifth  |
       +-------------+--------+ */
 
    for (let i = 0; i < 3; ++i) {
        let mText
        switch (i) {
            case 0:
                mText = 'first';
                break;
            case 1:
                mText = 'second';
                break;
            case 2:
                mText = 'third';
                break;
            case 3:
                mText = 'fourth';
                break;
            case 4:
                mText = 'fifth';
                break;
        }
        document.getElementsByTagName('div')[0].innerHTML += "This is the " + mText + " paragraph.<br/>";
    }
</script>
</body>
</html>

不是i++吗?还有i<3,i最多等于2