为什么 switch 语句不向应用程序提供 return 信息?

Why does the switch statement not return information to the app?

<!DOCTYPE html>
<html>

  <head>
  </head>

  <body>
    <input type="textArea" id="textSpot">
    <button onclick="changeHtml()">Encode!!!</button>
    <h2 id="afterEncode"></h2>
    <script>
    var textSpot = document.getElementById("textSpot").value
var letters = [text.charAt(0), text.charAt(1), text.charAt(2), text.charAt(3), text.charAt(4), text.charAt(5), text.charAt(6)]
var i = 0;
var code = "";

while (i < 10) {
  
    var code = ""
    switch (letters[i]) {
    case "a":
      code += "\"
      break;

    case "b":
      code += "^"
      break;

    case "c":
      code += "ø"
      break;

    case "d":
      code += "˜"
      break;

    case "e":
      code += "ˣ"
      break;

    case "f":
      code += "Ͱ"
      break;

    case "g":
      code += "Є"
      break;

    case "h":
      code += " г"
      break;

    case "i":
      code += "д"
      break;

    case "j":
      code += "ж"
      break;

    case "k":
      code += "л"
      break;

    case "l":
      code += "ѣ"
      break;

    case "m":
      code += "Ѳ"
      break;

    case "n":
      code += "҂"
      break;

    case "o":
      code += "Ӷ"
      break;

    case "p":
      code += "‡"
      break;

    case "q":
      code += "⁊"
      break;

    case "r":
      code += "※"
      break;

    case "s":
      code += "⁀"
      break;

    case "t":
      code += "‽"
      break;

    case "u":
      code += "₌"
      break;

    case "v":
      code += "₱"
      break;

    case "w":
      code += "∏"
      break;

    case "x":
      code += "≀"
      break;

    case "y":
      code += "⌗"
      break;

    case "z":
      code += "⌭"
      break;

    default:
      console.error("> Unexpected Syntax Error _ (Code: 231815147381181320518)")
  }
  i++
}

function changeHtml() {
  document.getElementById("afterEncode").innerHTML = ("<h2>" + code + "</h2>")
}

    </script>
  </body>

</html>

我不认为这有什么问题,所以请有人帮助我。我正在使用 Chrome,这是最新的浏览器之一,所以我认为它必须是代码。我不太擅长代码,这是作为更大版本的测试版本构建的。

我认为你应该在 var letters 中使用“textSpot”而不是“text”