Write Loop Javascript

admin
Arief Siswanto
2022-11-13 09:17:23
<html>
  <head>
    <title>Write Loop</title>
  </head>
  <body>
    <div id="target"></div>
    <script type="text/javascript" src="jquery-3.6.1.js"></script>
    <script type="text/javascript">
      $(function () {
        var string = "HELLO WORLD";
        var founded = "";
        for (x = 0; x < string.length; x++) {
          if (string.charAt(x) == " ") {
            founded += string.charAt(x);
            continue;
          }
          for (i = 65; i <= 90; i++) {
            if (String.fromCharCode(i) == string.charAt(x)) {
              founded += string.charAt(x);
              $("#target").append(founded);
              $("#target").append("<br />");
              break;
            } else {
              $("#target").append(String.fromCharCode(i));
              $("#target").append("<br />");
            }
          }
        }
      });
    </script>
  </body>
</html>
No reply found.