javascripttagsswitch-statementcorrectness

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>

I don't think anything is wrong with this, so could someone please help me. I am using Chrome, which is one of the most updated browsers, so I think it has to be the code. I'm not very good with code and this was built as a test version for a larger version.


Solution

  • I think you should use "textSpot" instead of "text" in var letters